package com.chernowii.hero4; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class MyPostNotificationReceiver2 extends BroadcastReceiver { public static final String CONTENT_KEY = "contentText"; public MyPostNotificationReceiver2() { } @Override public void onReceive(Context context, Intent intent) { Intent displayIntent = new Intent(context, MyDisplayActivity.class); String text = intent.getStringExtra(CONTENT_KEY); Notification notification = new Notification.Builder(context) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(text) .extend(new Notification.WearableExtender() .setDisplayIntent(PendingIntent.getActivity(context, 0, displayIntent, PendingIntent.FLAG_UPDATE_CURRENT))) .build(); ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(0, notification); Toast.makeText(context, context.getString(R.string.notification_posted), Toast.LENGTH_SHORT).show(); } }