关于Android Notification 点击 ,程序恢复最后操作页面(类似Android QQ)。Home 键
由于做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 ,