0
我在給定型號的Android手機上收到了推送通知,但是當我點擊通知時,它消失並且未打開應用程序。如果有人把我從這些問題中解救出來,我將不勝感激。Android推送通知不適用於型號vs450pp版本4.4.2
我在給定型號的Android手機上收到了推送通知,但是當我點擊通知時,它消失並且未打開應用程序。如果有人把我從這些問題中解救出來,我將不勝感激。Android推送通知不適用於型號vs450pp版本4.4.2
嘗試以下代碼可能適合你。
Intent intent = new Intent(this, MainActivity.class); //define your application activity name which you want to open.
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder mBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Application Title")
.setContentText(message)
.setContentIntent(pIntent)
.setSound(soundUri); //This sets the sound to play
notificationManager.notify(0, mBuilder.build());
這將是good..if你可以分享你的代碼implemented..or錯誤你得到.. – Meenal
你寫過builder.setContentIntent(的PendingIntent); – Srijith