Hallo! I have a question concerning notifications.
I want to create an application, that parses received SMS for a certain content. If the sms contains a certain content it is parsed and the data is extracted. A notification should be created and it should show up. When the user selects the notification, the application should be invoked with the extracted data. If the application is not running, it should be started. If it is already running, the instance should be displayed and processing the information. To solve this I did the following: A Broadcast receiver listens for SMS and parses them. To invoke the application I use the following code: *NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, tickerText, when); Bundle bundleNotification = creatingNotificationBundle(...); Intent notificationIntent = new Intent(Intent.ACTION_MAIN); notificationIntent.setClassName(...); notificationIntent.putExtras(bundleNotification); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); mNotificationManager.notify((int) System.currentTimeMillis(), notification); * The Activity that I invoke processes the Intent in the onCreate(...) method. This works fine when the application is not running. When I already have an instance running, it is invoked and no data is passed (or I'm not overwriting the correct methods). I have seen the an onResume() is invoked. But this method doesn't have an intent as a parameter. What is the best idea to solve this problem? I did an (in my opinion) very dirty workaround to get this work: - I created a temporary activity - I do the same code as above except that I invoke this new activity and set the flags* notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) and notificationIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)* - this activity sends first a Broadcast and than an Intent both forwarding the data previously parsed. Using this way the main application alwas gets the data. If it is already running it receives the broadcast and comes to front with the intent, if it is not running, it receives the data from the intent in the onCreate(...) method. But I don't think that this is the correct solution for this problem, since it seams quite dirty to create a dummy activity just for redirecting data and doing nothing else. Any ideas and suggestions would be highly appreciated. Thanks -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

