2013-10-15 303 views
0

我实现了来自Google通知示例的代码示例。它工作正常,直到Android 4.2.2,但不是从4.3(在我的Nexus 7 2013年)...我是唯一一个得到这个问题吗?我错过了一个新的通知方法吗?这里是我的简单代码:通知不适用于android 4.3?

final int NOTIFICATION_ID = 1; 
     NotificationManager mNotificationManager; 

     mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); 

     PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, HomeActivity.class), 0); 

     NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) 
     .setSmallIcon(R.drawable.icon) 
     .setContentTitle("Title") 
     .setStyle(new NotificationCompat.BigTextStyle() 
     .bigText("")) 
     .setContentText("Message"); 

     mBuilder.setContentIntent(contentIntent); 
     mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); 

谢谢!

回答

0

嗯,实际上问题来自于我的php文件的错误编码,无论出于何种原因,它都会跳过添加新用户(registration_id)到数据库的请求。 GCM服务器无法知道我的设备,因为它没有添加到数据库中...

问题是,它的工作原理是Android 4.3!