Hi All, I am starting activities from A->B->C in acttivity C i am creating a notification , when i click on the notification it opens A, but I want to open activity C. On back press from A it goes to C. I t shows there are mulitple instances of A created.A is the MAIN launcher activity How to avoid this situation?
PowerManager pm = (PowerManager) context .getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, "My Tag"); wl.acquire(); try { Intent tintent = new Intent(); Bundle bundle = intent.getExtras(); AlarmItem alarm = (AlarmItem) bundle.getSerializable("alarm"); String message = bundle.getString("alarm_message"); long when =Long.parseLong(alarm.getShow().getStart().getSec())*1000; //long when = 10000; tintent.putExtra("alarm_message", message); tintent.putExtra("isAlarm", true); tintent.putExtra("alarm", bundle.getSerializable("alarm")); final ActivityManager am =(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE); final List<RecentTaskInfo> recentTaskInfos = am.getRecentTasks(1024,0); String myPkgNm = context.getPackageName(); if(!recentTaskInfos.isEmpty()) { RecentTaskInfo recentTaskInfo; final int size = recentTaskInfos.size(); for(int i=0;i<size;i++) { recentTaskInfo = recentTaskInfos.get(i); if(recentTaskInfo.baseIntent.getComponent().getPackageName() .equals(myPkgNm)) { tintent = recentTaskInfo.baseIntent; tintent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); } } } PendingIntent pIntent = PendingIntent.getActivity(context, alarm.getId(), tintent,0); RemoteViews v = new RemoteViews("com.android", R.layout.notificationview); v.setTextViewText(R.id.notificationTitle, "Reminder: " + titleMessageToDisplay); v.setTextViewText(R.id.notificationContent, textMessageToDisplay); Bitmap image = Utility.getImageForAssets(context, alarm.getShow() .getIcon(), 2); if (image != null) v.setImageViewBitmap(R.id.showImage, image); Notification noti = new NotificationCompat.Builder(context) // .setContentTitle("Show Reminder") // .setContentInfo(messageToDisplay) // .setTicker(messageToDisplay) .setWhen(when) .setSmallIcon(R.drawable.notify) .setContentIntent(pIntent) .setContent(v) .setNumber(1) .setVibrate( new long[] { 100, 200, 200 }) .setSound( RingtoneManager .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .getNotification(); // noti.flags |= Notification.FLAG_AUTO_CANCEL; noti.flags = Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR; noti.setLatestEventInfo(context, "some Title", "some text", pIntent); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(alarm.getId(), noti); // Now that the notification has triggered, we can remove this from // the reminder list ReminderAlarmManager rm = new ReminderAlarmManager(context); rm.removeAlarm(alarm.getShow(), alarm.getId()); } catch (Exception e) { e.printStackTrace(); } finally { wl.release(); } in the manifest I have given android:allowTaskReparenting="true" android:launchMode="singleTop|singleInstance" for the main activity. Please reply. -- Regards, Vani Reddy -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en