2017-11-18 7 views
1

BroadcastReceiver()内の通知に問題が発生しました。 私が知っているように、私のコードは以前は正しく機能していましたが、今は動作しません。 NotificationTickerが表示されることもありますが、タイトルとコンテンツは表示されません。 ここに私のコードです。私の検索は私が問題がどこにあるのかを見つけるのを助けることができませんでした。ここBroadCastReceiver内の通知が機能しません

は私のコードです:

private void MyNotification(Context context) { 

    String NotificqationText = "NotificqationText"; 
    String NotificationTitle = "NotificationTitle "; 
    String NotificationTicker = "NotificationTicker"; 
    PendingIntent MyPendingIntent = PendingIntent.getActivity(context, 0, new Intent(context, Splash.class), 0); 


    NotificationCompat.Builder MyNB = new NotificationCompat.Builder(context); 
    MyNB.setSmallIcon(R.drawable.icon); 
    MyNB.setContentTitle(NotificationTitle); 
    MyNB.setContentText(NotificqationText); 
    MyNB.setTicker(NotificationTicker); 
    MyNB.setAutoCancel(true); 
    MyNB.setContentIntent(MyPendingIntent); 

    Bitmap MyPicture = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon); 
    MyNB.setLargeIcon(MyPicture); 

    NotificationCompat.BigPictureStyle MyPicStyle = new NotificationCompat.BigPictureStyle().bigPicture(MyPicture); 
    MyPicStyle.setSummaryText("Etude can makes our life Enlightened"); 
    MyNB.setStyle(MyPicStyle); 


    MyNB.setStyle(new NotificationCompat.BigTextStyle()); 
    NotificationCompat.BigTextStyle MyText = new NotificationCompat.BigTextStyle(); 
    MyText.bigText(NotificqationText); 
    MyText.setBigContentTitle(NotificationTitle); 

    NotificationManager MyNotifyManager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE); 
    MyNotifyManager.notify(1, MyNB.build()); 

} 

私は正常に動作し、通知のみが問題

+0

私はもう一度私のコードを確認したが、 "Clean Master"のようなアプリケーションは私の電話の中で私の通知をブロックされていた –

答えて

0

このコードを試してみてくださいしている私のbroadcastreceiverの作品を見つけるか、ブロードキャストを見つけるために、トーストメッセージを使用:

private void MyNotification(Context context) { 

    String NotificqationText = "NotificqationText"; 
    String NotificationTitle = "NotificationTitle "; 
    String NotificationTicker = "NotificationTicker"; 
    Intent intent = new Intent(this, Splash.class); 
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |(Intent.FLAG_ACTIVITY_SINGLE_TOP 
      | Intent.FLAG_ACTIVITY_CLEAR_TASK)); 
    PendingIntent MyPendingIntent = PendingIntent.getActivity(this, 0, 
      intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); 


    Bitmap MyPicture = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon); 

    Notification MyNB = new Notification.Builder(this) 
    .setSmallIcon(R.drawable.icon) 
    .setLargeIcon(MyPicture) 
    .setStyle() 
    .setBigContentTitle(NotificationTitle) 
    .setContentTitle(NotificationTitle) 
    .setContentText(NotificqationText) 
    .setTicker(NotificationTicker) 
    .setAutoCancel(true) 
    .setContentIntent(MyPendingIntent) 
    .build(); 
    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
    MyNB.flags |= Notification.FLAG_SHOW_LIGHTS; 
    MyNB.flags |= Notification.FLAG_AUTO_CANCEL; 
    MyNB.defaults = Notification.DEFAULT_ALL; 

    notificationManager.notify((int)System.currentTimeMillis(), MyNB); 
    } 
+0

"Clean Master"のようなアプリケーションが電話機の中の私の通知をブロックされていた。 –

関連する問題