展会信息港展会大全

关于Android Notification 点击 ,程序恢复最后操作页面(类似Android QQ)。Home 键
来源:互联网   发布日期:2015-10-02 21:52:38   浏览:1818次  

导读:由于做Android 播放器,要实现程序隐藏,展现,通过Notification 实现切换。Notification 代码如下:匀琀爀椀渀最 no...

由于做Android 播放器,要实现程序隐藏,展现,通过Notification实现切换。

Notification代码如下:

String notificationMessage = ((Audio) obj).name_label;

Notification notification = new Notification(R.drawable.icon,notificationMessage, System.currentTimeMillis());

try {

Intent contentIntent = new Intent(getApplicationContext(),

Class.forName("com.***.***.****")); // 加载类,如果直接通过类名,会在点击时重新加载页面,无法恢复最后页面状态。

contentIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, contentIntent,0);

notification.setLatestEventInfo(PlayerService.this,getString(R.string.app_name), notificationMessage,pendingIntent);

notification.flags |= Notification.FLAG_ONGOING_EVENT;

mNotificationManager.notify(id,notification);

} catch (ClassNotFoundException ex) {

// 日志

}

作者 闲坐敲棋

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港