我正在开发可以执行发送假短信和接收假短信的应用程序。如果我可以使用内置的SMS通知,但我不知道这样做的话,那会更好。因此,我使用下面的代码来生成通知,当我单击该通知时,没有任何反应。任何人都可以解决我的问题吗?单击该通知时,我需要打开“消息收件箱”。任何帮助,将不胜感激!
Uri sms_uri = Uri.parse("smsto:+92xxxxxxxx");
Intent sms_intent = new Intent(Intent.ACTION_SENDTO, sms_uri);
sms_intent.putExtra("sms_body", "Good Morning ! how r U ?");
PendingIntent contentIntent = PendingIntent.getService(context, 0, sms_intent, 0);
Resources res = context.getResources();
Notification noti = new Notification.Builder(context)
.setContentTitle(res.getString(R.string.app_name))
//.setContentText(res.getString(R.string.cancelText))
.setSmallIcon(android.R.drawable.ic_dialog_email)
.setTicker(res.getString(R.string.app_name))
// .setAutoCancel(true)
.setWhen(System.currentTimeMillis())
.setContentIntent(contentIntent)
.build();
NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(NOTIFICATION_SERVICE);
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, noti);
用
PendingIntent.getActivity(context, 0 , sms_intent, 0);
这可能会有所帮助!!!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句