2016-03-04 104 views
0

我在给定型号的Android手机上收到了推送通知,但是当我点击通知时,它消失并且未打开应用程序。如果有人把我从这些问题中解救出来,我将不胜感激。Android推送通知不适用于型号vs450pp版本4.4.2

+1

这将是good..if你可以分享你的代码implemented..or错误你得到.. – Meenal

+0

你写过builder.setContentIntent(的PendingIntent); – Srijith

回答

0

尝试以下代码可能适合你。

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