Question

I am launching activity from notification using

final Intent intent = new Intent(context, TestActivity.class);
        intent.setAction(Intent.ACTION_VIEW);
PendingIntent launcher = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        views.setOnClickPendingIntent(R.id.test_launch_btn, launcher);

If activity is not visible and I click on notification it is working fine. The problem is that in ICS if activity is already visible and I click from notification status bar does not slide up on click of notification whereas in Jellybean status bar slide up on click. Status bar is not collapsing on click in notification in ICS. What can be done to hide status bar on click of notification. I am using S3 running 4.0.4.

Was it helpful?

Solution

You're right, Honeycomb and ICS don't automatically close the notification panel when a button inside is clicked to launch an Activity. (At the time we didn't have a way to tell which of your notification's buttons were going to launch an Activity, nor could we intercept that click appropriately. It wouldn't have made sense to close the panel on any click, because it would have made things like music controllers really unpleasant.)

Here's what you can do: On HC+ICS, once your Activity has been started this way, you can broadcast Intent.ACTION_CLOSE_SYSTEM_DIALOGS to explicitly close the notification panel. Only do this on pre-Jelly Bean devices, and only if your activity has been started in response to your own notification's PendingIntent.

Note that this is still the only way to close the panel on Jelly Bean if your notification's buttons use broadcast intents instead of starting activities.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top