2016-12-19 12 views
0

私は偽のSMSを送信して偽のテキストメッセージを受信できるアプリを開発中です。内蔵のSMS通知を使用することはできますが、その方法はわかりません。だから私は下のコードを使用して通知を生成し、その通知をクリックすると何も起こりません。誰も私の問題を解決できますか?その通知をクリックすると、メッセージ受信トレイを開く必要があります。どんな助けもありがとう!Androidの通知onClickアクティビティのオープンに失敗しました

助けるかもしれ
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); 

答えて

2

使用

PendingIntent.getActivity(context, 0 , sms_intent, 0); 

+0

素敵な仲間が働いています..あなたは私の一日を過ごしました;)多くの多くの感謝 –

+0

あなたを助けてくれてうれしい! –

関連する問題