
通过AlarmManager启动服务时,我使用以下代码启动通知:
@H_301_4@nm = (notificationmanager) this.getSystemService(Context.NOTIFICATION_SERVICE);CharSequence from = "App";CharSequence message = "Getting Latest Info...";PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0);Notification notif = new Notification(R.drawable.icon, "Getting Latest Info...", System.currentTimeMillis());notif.setLatestEventInfo(this, from, message, contentIntent);nm.notify(1, notif);如何设置此项目的意图,以便当用户点击它时,它会启动某个活动?
解决方法:
您基本上需要将Activity类作为意图的一部分放入PendingIntent中.目前你的Intent是空的.要重定向到新活动,它应该是:
@H_301_4@// This line of yours should contain the activity that you want to launch. // You are currently just passing empty new Intent()PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MyActivity.class), 0); 总结 以上是内存溢出为你收集整理的android – 如何设置通知的点击监听器?全部内容,希望文章能够帮你解决android – 如何设置通知的点击监听器?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)