I am working on an app that shows a notification that uses a custom layout (notification.contentView = remoteViews), that contains a button. First of all, I am aware that there are new APIs to do this in 4.1 but my app has to work on 4.0. I want the button to start an activity so I do this: Intent clickIntent = new Intent(this, MyActivity.class); clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); contentView.setOnClickPendingIntent(R.id.button, PendingIntent.getActivity(this, 0, clickIntent, PendingIntent.FLAG_CANCEL_CURRENT));
This works as intended, but my problem is: - On a 4.1 Galaxy Nexus, when clicking on the button, the notification bar collapses, thus the newly displayed activity is visible to the user (the behavior I want!) - On a 4.0 emulator, when clicking on the button, the notification bar stays open, thus the newly displayed activity is not visible to the user
Does anybody know if there is a way to control this, so the bar will also close on 4.0?
On Fri, Oct 12, 2012 at 8:14 AM, BoD <bodlu...@gmail.com> wrote:
> Hi!
> I am working on an app that shows a notification that uses a custom layout
> (notification.contentView = remoteViews), that contains a button.
> First of all, I am aware that there are new APIs to do this in 4.1 but my
> app has to work on 4.0.
> I want the button to start an activity so I do this:
> Intent clickIntent = new Intent(this, MyActivity.class);
> clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
> contentView.setOnClickPendingIntent(R.id.button,
> PendingIntent.getActivity(this, 0, clickIntent,
> PendingIntent.FLAG_CANCEL_CURRENT));
> This works as intended, but my problem is:
> - On a 4.1 Galaxy Nexus, when clicking on the button, the notification bar
> collapses, thus the newly displayed activity is visible to the user (the
> behavior I want!)
> - On a 4.0 emulator, when clicking on the button, the notification bar
> stays open, thus the newly displayed activity is not visible to the user
> Does anybody know if there is a way to control this, so the bar will also
> close on 4.0?
> Thanks a lot,
> --
> BoD
> --
> 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+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> On Fri, Oct 12, 2012 at 8:14 AM, BoD <bodl...@gmail.com <javascript:>>wrote:
>> Hi!
>> I am working on an app that shows a notification that uses a custom >> layout (notification.contentView = remoteViews), that contains a button. >> First of all, I am aware that there are new APIs to do this in 4.1 but my >> app has to work on 4.0. >> I want the button to start an activity so I do this: >> Intent clickIntent = new Intent(this, MyActivity.class); >> clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); >> contentView.setOnClickPendingIntent(R.id.button, >> PendingIntent.getActivity(this, 0, clickIntent, >> PendingIntent.FLAG_CANCEL_CURRENT));
>> This works as intended, but my problem is: >> - On a 4.1 Galaxy Nexus, when clicking on the button, the notification >> bar collapses, thus the newly displayed activity is visible to the user >> (the behavior I want!) >> - On a 4.0 emulator, when clicking on the button, the notification bar >> stays open, thus the newly displayed activity is not visible to the user
>> Does anybody know if there is a way to control this, so the bar will also >> close on 4.0?
>> Thanks a lot,
>> -- >> BoD
>> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-d...@googlegroups.com<javascript:> >> To unsubscribe from this group, send email to >> android-developers+unsubscribe@googlegroups.com <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en
On Friday, October 12, 2012 4:14:17 PM UTC+2, BoD wrote:
> Hi!
> I am working on an app that shows a notification that uses a custom layout > (notification.contentView = remoteViews), that contains a button. > First of all, I am aware that there are new APIs to do this in 4.1 but my > app has to work on 4.0. > I want the button to start an activity so I do this: > Intent clickIntent = new Intent(this, MyActivity.class); > clickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); > contentView.setOnClickPendingIntent(R.id.button, > PendingIntent.getActivity(this, 0, clickIntent, > PendingIntent.FLAG_CANCEL_CURRENT));
> This works as intended, but my problem is: > - On a 4.1 Galaxy Nexus, when clicking on the button, the notification bar > collapses, thus the newly displayed activity is visible to the user (the > behavior I want!) > - On a 4.0 emulator, when clicking on the button, the notification bar > stays open, thus the newly displayed activity is not visible to the user
> Does anybody know if there is a way to control this, so the bar will also > close on 4.0?