List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TOP
int FLAG_ACTIVITY_CLEAR_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TOP.
Click Source Link
From source file:br.com.bign.push.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*w ww .j a v a2s . c om*/ */ private void sendNotification(String message, String title) { 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.mipmap.ic_launcher).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); Random random = new Random(); notificationManager.notify(random.nextInt(), notificationBuilder.build()); }
From source file:com.anypresence.android.notifications.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//ww w . ja va 2s .com */ private void sendNotification(String message) { Intent intent = new Intent(this, ContentPageHomePageView.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_launcher).setContentTitle("Notification Kit Message") .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:co.hackingedu.ro.backend.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// w w w .j ava 2 s .c o m */ private void sendNotification(String message) { 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.mipmap.ic_launcher).setContentTitle(NOTIFICATION_TITLE).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:cl.apd.ditapp.network.gcm.DitappGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param data GCM message received.//from w w w .j ava 2 s . c om */ private void sendNotification(final Bundle data) { RealmConfiguration realmConfig = new RealmConfiguration.Builder(this).build(); Realm realm = Realm.getInstance(realmConfig); realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { Notificacion notificacion = realm.createObject(Notificacion.class); notificacion.setTitulo(data.getString(Constants.NOTIFICACION_TITULO)); notificacion.setDescripcion(data.getString(Constants.NOTIFICACION_DESCRIPCION)); notificacion.setFecha(new Date()); } }); 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.mipmap.ic_launcher).setContentTitle(data.getString(Constants.NOTIFICACION_TITULO)) .setContentText("un mensaje").setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:co.org.cut.cut_app.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//ww w . j a v a 2 s . c o m */ private void sendNotification(String title, String message, String tipo, String id) { Intent intent = new Intent(this, Contenedor.class); intent.putExtra(ARG_TITLE, title); intent.putExtra(ARG_MSG, message); intent.putExtra(ARG_TYPE, tipo); intent.putExtra(ARG_ID, id); 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_launcher).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.baasio.sample.startup.gcm.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///from www.jav a2 s. c o m private static void generateNotification(Context context, String message) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(context, MainActivity.class); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); Notification notification = new NotificationCompat.Builder(context).setWhen(when).setSmallIcon(icon) .setContentTitle(context.getString(R.string.app_name)).setContentText(message) .setContentIntent(intent).setTicker(message).setAutoCancel(true).getNotification(); notificationManager.notify(0, notification); }
From source file:com.irontec.fragments.EzarpenakFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);//from w w w .j a va2s .c o m mContext = getActivity().getBaseContext(); View rootView = inflater.inflate(R.layout.fragment_ezarpenak, container, false); mViewSwitcher = (ViewSwitcher) rootView.findViewById(R.id.viewSwitcher1); mEzarpenZerrenda = (ListView) rootView.findViewById(R.id.ezarpenak_list); mItems = new ArrayList<BasicNameValuePair>(); BasicNameValuePair item1 = new BasicNameValuePair("Saioa itxi", ""); BasicNameValuePair item2 = new BasicNameValuePair("Sare sozialak", "Zure sare sozialak kudeatu"); BasicNameValuePair item3 = new BasicNameValuePair("Lizentziak", "Erabilitako baliabideak"); BasicNameValuePair item4 = new BasicNameValuePair("Honi buruz", ""); mItems.add(item1); mItems.add(item2); mItems.add(item3); mItems.add(item4); mEzarpenZerrenda.setAdapter(new SimpleLicenseAdapter(mContext, mItems)); mEzarpenZerrenda.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { Intent intent = null; if (position == 0) { MintzatuAPI.logout(mContext); intent = new Intent(getActivity().getBaseContext(), LoginCircles.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); if (getActivity() != null) { getActivity().finish(); } } else if (position == 3) { intent = new Intent(mContext, HoniBuruzActivity.class); } else { intent = new Intent(mContext, EzarpenakDetailActivity.class); } switch (position) { case 1: intent.putExtra("detail_type", 0); break; case 2: intent.putExtra("detail_type", 1); break; default: break; } if (intent != null) { startActivity(intent); } } }); mViewSwitcher.showNext(); return rootView; }
From source file:asia.covisoft.goom.gcm.GoOmGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//www .j a va 2 s. c o m */ private void sendNotification(String title, String message) { 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_ic_notification).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.github.wakhub.monodict.activity.bean.ActivityHelper.java
/** * http://stackoverflow.com/questions/6547969/android-refresh-current-activity *//*from w w w. j a va 2 s.c o m*/ public void restartActivity() { Intent intent = new Intent(activity, activity.getClass()); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); activity.finish(); activity.startActivity(intent); }
From source file:br.com.commons.pushnotification.views.service.GcmCustomListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from www .ja v a 2 s . co m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, HomeActivity.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.common_google_signin_btn_icon_dark).setContentTitle("GCM Message") .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }