Android通知onClick活动打开失败

Android通知onClick活动打开失败,android,sms,android-notifications,Android,Sms,Android Notifications,我正在开发可以发送假短信和接收假短信的应用程序。如果我能使用内置的短信通知会更好,但我不知道该怎么办。因此,我使用下面的代码生成通知,当我单击该通知时,什么也没有发生。谁能解决我的问题?我需要在单击该通知时打开邮件收件箱。任何帮助都将不胜感激 Uri sms_uri = Uri.parse("smsto:+92xxxxxxxx"); Intent sms_intent = new Intent(Intent.ACTION_SENDTO, sms_uri); sms_intent.putExtra

我正在开发可以发送假短信和接收假短信的应用程序。如果我能使用内置的短信通知会更好,但我不知道该怎么办。因此,我使用下面的代码生成通知,当我单击该通知时,什么也没有发生。谁能解决我的问题?我需要在单击该通知时打开邮件收件箱。任何帮助都将不胜感激

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);