2017-02-04 9 views
2

私のアプリでは通知を受け取り、ログに表示することができます。しかし、いくつかの携帯電話では、彼らは表示されていません。例:One plus A0001(Android 5.1.1 API22)。私は他のスタックオーバーフローに関する質問を読んで、すべての必要なメソッドがそこにあることを確認しました。調査の結果、Cyanogenmodがこれの理由かもしれないことがわかりました。アプリの通知が表示されます。一部のAndroid携帯端末で通知が表示されない

public class MainActivity extends AppCompatActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    Intent intent = new Intent(this, MainActivity.class); 
    PendingIntent pIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, 0); 
    Notification n = new Notification.Builder(this) 
      .setContentTitle("New mail from " + "[email protected]") 
      .setContentText("Subject") 
      .setSmallIcon(R.drawable.ic_launcher) 
      .setContentIntent(pIntent) 
      .setAutoCancel(true).build(); 

    NotificationManager notificationManager = 
      (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 

    notificationManager.notify(6578, n); 
} 

上記のコードは他のすべての携帯端末で機能します。

+0

「NotificationCompat」の使用をお試しください。試してみます。 – Wizard

+0

@Wizardすでにそれを試しました。しかし使用しない –

答えて

0

アプリの通知権限を確認してください。あなたの携帯電話の制御。おそらく、設定やプリインストールされたアプリにあります。 特に中国では、多くの携帯電話にサードパーティのアプリの権限を制御するための「权限管家」というアプリがプリインストールされています。通知バーに通知を表示する、背景を実行している間、または画面がロックされているときにインターネットに接続するなど。

+0

私はそれらの設定をチェック@Oscar Zhang –

関連する問題