按Notification 回到正在运行的activity

简介: 写好Notification , 按Home回到主界面,再按通知栏的消息(Notification), 回到退出之前正在运行的Acticity .     在代码中加入两行代码作为声名即可。 :                                  Intent notificationIntent = new Intent(this,this.

  写好Notification , 按Home回到主界面,再按通知栏的消息(Notification), 回到退出之前正在运行的Acticity .

    在代码中加入两行代码作为声名即可。 :

                 
                 Intent notificationIntent = new Intent(this,this.getClass()); 

                /* */
                notificationIntent.setAction(Intent.ACTION_MAIN);
                notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                 

                PendingIntent contentIntent = PendingIntent.getActivity(this.context, 0, notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
                notification.setLatestEventInfo(context, title, text, contentIntent);        
                mNotificationManager.notify(NOTIFICATION_SERVICE_ID,notification);

 

 

 

目录
相关文章
|
监控 安全 C#
attempt to write a readonly database错误的解决(C#,SQLite)
今天打包WPF程序,安装后总是打不开,查看监控日志原来是SQLite的问题,报错如图     当向SQLite数据库中存入新纪录时总是显示attempt to write a readonly a database。
3546 0
|
10月前
|
缓存 Java 数据库
Android的ANR原理
【10月更文挑战第18天】了解 ANR 的原理对于开发高质量的 Android 应用至关重要。通过合理的设计和优化,可以有效避免 ANR 的发生,提升应用的性能和用户体验。
465 56
|
数据采集 安全 网络协议
信息安全管理与评估赛题第2套(上)
一共打算发三套样题 后边给大家发师傅们的学习笔记以及对一些题的理解
452 0
|
JavaScript 前端开发
document.write和innerHTML、innerText 的区别
document.write和innerHTML、innerText 的区别
209 5
|
数据库 开发工具 开发者
【Python】已解决:You have 18 unapplied migration(s). Your project may not work properly until you apply t
【Python】已解决:You have 18 unapplied migration(s). Your project may not work properly until you apply t
661 0
|
存储 Ubuntu Shell
mac docker镜像在哪个文件夹
【2月更文挑战第22天】
1786 0
|
存储 XML 监控
启动优化 · 基础论 · 浅析Android启动优化
启动优化 · 基础论 · 浅析Android启动优化
715 0
启动优化 · 基础论 · 浅析Android启动优化
|
缓存 Go
深度探索 Go 对象模型(三)
深度探索 Go 对象模型(三)
137 0
|
SQL 存储 程序员
SQL Server——SQL Server触发器及事务和锁
SQL Server——SQL Server触发器及事务和锁
560 1