List of usage examples for android.content Intent FLAG_ACTIVITY_SINGLE_TOP
int FLAG_ACTIVITY_SINGLE_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_SINGLE_TOP.
Click Source Link
From source file:com.chute.android.photopickerplus.util.intent.IntentUtil.java
public static void deliverDataToInitialActivity(final FragmentActivity context, final List<AssetModel> collection) { final PhotoPickerPlusIntentWrapper wrapper = new PhotoPickerPlusIntentWrapper( new Intent(context, ServicesActivity.class)); wrapper.setMediaCollection(collection); wrapper.getIntent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); wrapper.startActivity(context);/*from www.jav a 2s . c o m*/ }
From source file:net.pocketmine.server.ServerService.java
@SuppressWarnings("deprecation") private void run() { if (!isRunning) { isRunning = true;//from ww w . j a va 2s . c o m android.support.v4.app.NotificationCompat.Builder note = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.pm_chars) .setContentTitle(getResources().getString(R.string.service_running)) .setWhen(System.currentTimeMillis()); Intent i = new Intent(this, HomeActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0); note.setContentText(getResources().getString(R.string.tap_open)); note.setContentIntent(pi); note.setOngoing(true); note.addAction(R.drawable.ic_action_cancel, getResources().getString(R.string.stop), PendingIntent.getBroadcast(this, 0, new Intent(getPackageName() + ".EX_COMMAND").putExtra("cmd", "stop"), 0)); startForeground(1337, note.build()); } }
From source file:com.monkey.entonado.AlarmReciever.java
@Override public void onReceive(Context context, Intent intent) { System.out.println("llego a recieve ------------------"); // TODO Auto-generated method stub Intent in = new Intent(context, MainActivity.class); in.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(context, 1994, in, PendingIntent.FLAG_ONE_SHOT); NotificationManager manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); NotificationCompat.Builder not = new NotificationCompat.Builder(context); not.setSmallIcon(android.R.drawable.ic_popup_sync).setAutoCancel(true) .setContentTitle("Ya han pasado 20 minutos").setContentText("Toca para pedir ms canciones") .setTicker("Ya puedes mandar canciones!").setContentIntent(pi); Notification noti = not.build(); noti.flags |= Notification.FLAG_ONGOING_EVENT; manager.notify(MainActivity.TAG, 0, noti); }
From source file:com.getchute.android.photopickerplus.util.intent.IntentUtil.java
public static void deliverDataToInitialActivity(final FragmentActivity context, final List<AssetModel> collection, AccountModel accountModel) { final PhotoPickerPlusIntentWrapper wrapper = new PhotoPickerPlusIntentWrapper( new Intent(context, ServicesActivity.class)); wrapper.setMediaCollection(collection); if (accountModel != null) { wrapper.setAccountModel(accountModel); }/*from w w w . j a va2 s .co m*/ wrapper.getIntent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); wrapper.startActivity(context); }
From source file:gcm.GcmMessageHandler.java
private void createNotification(String title, String body) { Context context = getBaseContext(); int defaults = 0; defaults = defaults | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND | Notification.FLAG_AUTO_CANCEL; Intent notificationIntent = new Intent(context, ConversationActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIndent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setContentText(body) .setDefaults(defaults).setStyle(new NotificationCompat.BigTextStyle().bigText(body)) .setContentIntent(contentIndent).setAutoCancel(true); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mBuilder.build()); }
From source file:com.example.joeroger.sampleplaces.activity.LicenseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); switch (id) { case android.R.id.home: Intent intent = NavUtils.getParentActivityIntent(this); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); NavUtils.navigateUpTo(this, intent); return true; default://from www . ja va2 s.co m return super.onOptionsItemSelected(item); } }
From source file:com.simplaapliko.wakeup.sample.util.SendNotification.java
@Override public void onHandle(Context context, Intent intent) { Alarm alarm = intent.getParcelableExtra(AlarmController.EXTRA_ALARM); int smallIcon = R.mipmap.ic_launcher; int notificationId = (int) alarm.getId(); long externalId = alarm.getExternalId(); String title = alarm.getTitle(); String text = alarm.getMessage(); long when = alarm.getTime(); Notification notification;//from ww w . ja v a2s. c om Intent receiver = new Intent(context, MainActivity.class); receiver.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); receiver.putExtra(MainActivity.ALARM_ID_KEY, externalId); PendingIntent pi = PendingIntent.getActivity(context, notificationId, receiver, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(text).setAutoCancel(true).setSmallIcon(smallIcon).setContentIntent(pi); if (when != Alarm.NOT_SET) { builder.setWhen(when); } builder.setLights(0xFFFF0000, 1000, 4000); builder.setSound(Uri.parse("content://media/internal/audio/media/33")); builder.setVibrate(new long[] { 1000, 500, 500, 500 }); notification = builder.build(); //notification.flags |= Notification.FLAG_SHOW_LIGHTS; //notification.defaults |= Notification.DEFAULT_LIGHTS; //notification.defaults |= Notification.DEFAULT_SOUND; //notification.defaults |= Notification.DEFAULT_VIBRATE; NotificationManager nm = getNotificationManager(context); nm.notify(notificationId, notification); }
From source file:com.blackcrowsteam.musicstop.NotificationHelper.java
/** * Show notification//from www . j a v a 2 s . c o m * @param s Service * @param title title * @param message message */ public void setMessage(Service s, CharSequence title, CharSequence message) { Context context = s.getApplicationContext(); Intent notificationIntent = new Intent(context, StopActivity.class) .setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); Notification notif = new NotificationCompat.Builder(context).setContentTitle(title).setContentText(message) .setContentIntent(contentIntent).setSmallIcon(R.drawable.ic_launcher).setOngoing(true).setWhen(time) .build(); // Pass the Notification to the NotificationManager: getManager(context).notify(id, notif); s.startForeground(id, notif); }
From source file:com.tcnr14.example.GCMIntentService.java
private static void generateNotification(Context context, Bundle data) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Intent ni = new Intent(context, MainActivity.class); ni.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, ni, 0); Notification noti = new NotificationCompat.Builder(context).setContentTitle("GCM")//Title .setContentText(data.getString("Notice"))// .setContentIntent(intent)//?? .setDefaults(Notification.DEFAULT_ALL)//????(+) .setSmallIcon(icon)//?icon .setWhen(when).build();// nm.notify(0, noti);//from w ww. j av a2s.co m }
From source file:com.github.vase4kin.teamcityapp.about.AboutActivity.java
/** * Start About activity with Flag {@link Intent#FLAG_ACTIVITY_SINGLE_TOP} *///from ww w . j a v a2 s . c o m public static void start(Activity activity) { Intent launchIntent = new Intent(activity, AboutActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); DrawerActivityStartUtils.startActivity(launchIntent, activity); }