简体   繁体   English

单击通知后,Android ICS状态栏不会隐藏

[英]Android ICS status bar not hiding on click of notification

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. 问题在于,在ICS如果活动已经可见并且我从通知状态栏单击,则单击通知时不会向上滑动,而在Jellybean状态栏中,单击时会向上滑动。 Status bar is not collapsing on click in notification in ICS. ICS中的单击通知时,状态栏不会折叠。 What can be done to hide status bar on click of notification. 单击通知后如何隐藏状态栏。 I am using S3 running 4.0.4. 我正在使用运行4.0.4的S3。

You're right, Honeycomb and ICS don't automatically close the notification panel when a button inside is clicked to launch an Activity. 没错,当单击内部按钮以启动活动时,Honeycomb和ICS不会自动关闭通知面板。 (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. 您可以执行以下操作:在HC + ICS上,以这种方式启动活动后,您可以广播Intent.ACTION_CLOSE_SYSTEM_DIALOGS以显式关闭通知面板。 Only do this on pre-Jelly Bean devices, and only if your activity has been started in response to your own notification's PendingIntent. 仅在果冻Bean之前的设备上执行此操作,并且仅当您的活动已响应您自己的通知的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. 请注意,如果您的通知按钮使用广播意图而不是开始活动,这仍然是关闭Jelly Bean面板的唯一方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM