For some reason, the notification that I create is disappearing in
about 5 seconds without any action on my part. I can see it appear
(with a message in the title bar). Then, when I pull down the message
bar, I see the notification in the list for about 5 seconds and then
it just disappears! Non of the documentation addresses this behavior
so I'm not sure where to go with this.
Here's a couple examples of code that I've tried (all result in the
same behavior described):
Notification.Builder setupGoogleActBuilder = new
Notification.Builder( context );
setupGoogleActBuilder.setSmallIcon( R.drawable.notification_gear );
setupGoogleActBuilder.setTicker( context.getResources().getString(
R.string.notification_setup_google_title ) );
setupGoogleActBuilder.setContentTitle( context.getResources().getString(
R.string.notification_setup_google_title ) );
setupGoogleActBuilder.setContentText( context.getResources().getString(
R.string.notification_setup_google_body ) );
Intent googleAccountIntent = new Intent();
googleAccountIntent.setAction( "android.settings.ADD_ACCOUNT_SETTINGS" );
PendingIntent googleAccountPendingIntent =
PendingIntent.getActivity( context, 0, googleAccountIntent, 0 );
setupGoogleActBuilder.setContentIntent( googleAccountPendingIntent );
setupGoogleActBuilder.setAutoCancel( true );
notification = setupGoogleActBuilder.getNotification();
...as well as the deprecated version:
notification = new Notification(
R.drawable.notification_gear,
context.getResources().getString(R.string.notification_setup_google_title),
System.currentTimeMillis());
notification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent googleAccountIntent = new Intent();
googleAccountIntent.setAction( "android.settings.ADD_ACCOUNT_SETTINGS" );
PendingIntent googleAccountPendingIntent =
PendingIntent.getActivity( context, 0, googleAccountIntent, 0 );
notification.setLatestEventInfo(
context,
context.getResources().getString( R.string.notification_setup_google_title ),
context.getResources().getString( R.string.notification_setup_google_body ),
googleAccountPendingIntent);
I should note that:
1.) This is a SetupWizard application so it's sending the notification
during the initial startup after a factory reset:
<activity android:name=".ui.SetupWizardActivity"
android:label="@string/app_name" android:screenOrientation="portrait">
<intent-filter android:priority="500">
<action android:name="android.intent.action.MAIN" />
<action
android:name="android.intent.action.UPGRADE_SETUP" />
<category android:name="android.intent.category.HOME" /
>
<category
android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
2.) We've seen this occur only in Ice Cream Sandwich devices - it has
functioned correctly in the other android versions (Jelly Bean, and
prior to ICS) - the notification does not disappear.
Thanks in advance for your help!
--
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