Skip to content

Instantly share code, notes, and snippets.

@saturov
Last active August 29, 2015 14:28
Show Gist options
  • Save saturov/3adc2c513bd059d5ca3b to your computer and use it in GitHub Desktop.
Save saturov/3adc2c513bd059d5ca3b to your computer and use it in GitHub Desktop.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
Button wearButton = (Button)findViewById(R.id.wearButton);
wearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int notificationId = 001;
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(MainActivity.this)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Title")
.setContentText("Android Wear Notification");
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(MainActivity.this);
notificationManager.notify(notificationId, notificationBuilder.build());
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment