List of usage examples for android.app PendingIntent getActivity
public static PendingIntent getActivity(Context context, int requestCode, Intent intent, @Flags int flags)
From source file:augsburg.se.alltagsguide.gcm.command.AnnouncementCommand.java
private void displayNotification(Context context, String message) { Ln.i("Displaying notification: " + message); ((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(0, new NotificationCompat.Builder(context).setWhen(System.currentTimeMillis()) .setSmallIcon(R.mipmap.ic_launcher).setTicker(message) .setContentTitle(context.getString(R.string.app_name)).setContentText(message) .setColor(ContextCompat.getColor(context, R.color.primary)) .setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, OverviewActivity.class).setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP), 0))//from w w w . j a v a2 s.c om .setAutoCancel(true).build()); }
From source file:at.ac.uniklu.mobile.sportal.notification.GCMUtils.java
public static NotificationCompat.Builder getBroadcastMessageNotification(Context context, CharSequence message, String url) {/*from ww w .j a v a 2 s.c o m*/ NotificationCompat.Builder nb = getDefaultNotification(context).setContentText(message) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)); Intent i; if (url != null) { i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); } else { i = new Intent(); } PendingIntent pi = PendingIntent.getActivity(context, 0, i, Intent.FLAG_ACTIVITY_NEW_TASK); nb.setContentIntent(pi); return nb; }
From source file:com.networkmanagerapp.RestartWifi.java
/** * Notifies the user of progress in the system notification area *//*www. j av a2 s . c o m*/ private void showNotification() { CharSequence text = getText(R.string.wifi_service_restarted); Notification notification = new Notification(R.drawable.ic_stat_networkman, text, System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, NetworkManagerMainActivity.class), 0); notification.setLatestEventInfo(this, text, text, contentIntent); mNM.notify(R.string.wifi_service_restarted, notification); }
From source file:adapter.notification.MyFcmListenerService.java
private void sendNotification(RemoteMessage.Notification notification) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_utn).setContentTitle(notification.getTitle()) .setContentText(notification.getBody()).setGroup(notification.getTag()).setAutoCancel(true) .setColor(ContextCompat.getColor(getApplicationContext(), R.color.caldroid_holo_blue_dark)) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of adapter.notification */, notificationBuilder.build()); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToWebSessionObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String arg = obj.optString(ARG); Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra("android.intent.extra.APPLICATION_ARGUMENT", arg); launch.putExtra("creator", false); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String webUrl = obj.optString(WEB_URL); launch.setData(Uri.parse(webUrl));//from w w w . jav a2 s . co m PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received", "Click to launch application.", contentIntent); }
From source file:com.chefsglass.StopwatchService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (mLiveCard == null) { mLiveCard = new LiveCard(this, LIVE_CARD_TAG); new GetRecipeTask(new GetRecipeRequest(1l)).execute(); // Keep track of the callback to remove it before unpublishing. mCallback = new RecipeDrawer(this); mLiveCard.setDirectRenderingEnabled(true).getSurfaceHolder().addCallback(mCallback); Intent menuIntent = new Intent(this, MenuActivity.class); menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0)); mLiveCard.attach(this); mLiveCard.publish(PublishMode.REVEAL); } else {/*w w w .j a v a2s .c om*/ mLiveCard.navigate(); } return START_STICKY; }
From source file:edu.cmu.plugins.SmsPlugin.java
private void sendSMS(String phoneNumber, String message) { SmsManager manager = SmsManager.getDefault(); PendingIntent sentIntent = PendingIntent.getActivity(this.ctx, 0, new Intent(), 0); manager.sendTextMessage(phoneNumber, null, message, sentIntent, null); }
From source file:com.phonegap.helloworld.SmsPlugin.java
private void SendSMS(String phoneNumber, String message) { SmsManager manager = SmsManager.getDefault(); PendingIntent sentIntent = PendingIntent.getActivity(this.ctx.getContext(), 0, new Intent(), 0); manager.sendTextMessage(phoneNumber, null, message, sentIntent, null); }
From source file:com.manning.androidhacks.hack046.helper.NotificationHelper.java
private static PendingIntent getReplyPendingIntent(Context ctx) { Intent intent = new Intent(ctx, ReplyActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); return PendingIntent.getActivity(ctx, 0, intent, 0); }
From source file:com.networkmanagerapp.SettingBackgroundUploader.java
/** * Create a notification to inform the user of progress in the system notification area *///w ww . j a v a2 s .c o m private void showNotification() { CharSequence text = getText(R.string.upload_service_started); Notification notification = new Notification(R.drawable.ic_stat_networkman, text, System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, NetworkManagerMainActivity.class), 0); notification.setLatestEventInfo(this, text, text, contentIntent); mNM.notify(R.string.upload_service_started, notification); }