android – 如何隐藏活动?

android – 如何隐藏活动?,第1张

概述我有Activity下载正在进行的文件对话框.当用户按下“隐藏”按钮时,活动会创建通知并隐藏进度对话框.当用户单击通知时,活动将再次显示活动中的进度对话框.按下“返回”按钮后,如何将活动切换到后退任务? 您需要做的是调用finish()从堆栈中删除Activity. 然后在通知中,设置单击时要调用的Activity的名称,如下所示: NotificationManager notification 我有Activity下载正在进行的文件对话框.当用户按下“隐藏”按钮时,活动会创建通知并隐藏进度对话框.当用户单击通知时,活动将再次显示活动中的进度对话框.按下“返回”按钮后,如何将活动切换到后退任务?解决方法 您需要做的是调用finish()从堆栈中删除Activity.
然后在通知中,设置单击时要调用的Activity的名称,如下所示:

notificationmanager notificationmanager = (notificationmanager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon,"A new notification",System.currentTimeMillis());// Specify the called ActivityIntent intent = new Intent(this,YourActivityname.class);intent.putBoolean("isDownloading",true); // check this value in ActivityPendingIntent activity = PendingIntent.getActivity(this,intent,0);notification.setLatestEventInfo(this,"This is the Title","This is the text",activity);notificationmanager.notify(0,notification);
总结

以上是内存溢出为你收集整理的android – 如何隐藏活动?全部内容,希望文章能够帮你解决android – 如何隐藏活动?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1129794.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存