2013-10-15 60 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!