2016-09-28 4 views
0

私のJavaコード:以下のコードを使用していますが、動作しません。Facebookのようなロリポップバージョンの通知アイコンを設定する方法

Intent intent = new Intent(context, LiveFeedScreen.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); 
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 
    final int not_nu = generateRandom(); 
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 
      not_nu, intent, PendingIntent.FLAG_ONE_SHOT); 
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
      context) 
      .setSmallIcon(R.drawable.notificationbig_icon) 
      .setColor(context.getResources().getColor(R.color.header_blue)) 
      .setContentTitle(context.getString(R.string.app_name)) 
      .setContentText(mMessage) 
      .setAutoCancel(true) 
      .setStyle(
        new NotificationCompat.BigTextStyle().bigText(mMessage)) 
      .setContentIntent(pendingIntent); 
    NotificationManager notificationManager = (NotificationManager) context 
      .getSystemService(Context.NOTIFICATION_SERVICE); 

    notificationManager.notify(not_nu, notificationBuilder.build()); 

これはロリポップの下でのみ動作しますが、そのイメージは非常に小さく表示されます。

+2

画像の解像度が適切なサイズでない場合がありますか?異なるデバイスでそれを比較し、イメージのサイズが一貫しているかどうかを確認してください。 – Subby

+1

あなたの要件に合わせてチェックしてください。

+0

ic_launcherを同じアイコンに設定してください。 .setLargeIcon(BitmapFactory.decodeResource(context.getResources()、R.mipmap.ic_launcher)) –

答えて

0

使用すると、1つ下に試みることができる: `ます。private void Notifyを(文字列notificationMessage、文字列pushFullMessage){

Intent intent = new Intent(this, GCMNotificationActivity.class); 
    intent.putExtra("pushNotification", pushFullMessage); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    final int not_nu = generateRandom(); 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 
      not_nu, intent, PendingIntent.FLAG_ONE_SHOT); 


    android.support.v4.app.NotificationCompat.Builder notificationBuilder = new android.support.v4.app.NotificationCompat.Builder(
      this) 
      .setSmallIcon(R.drawable.app_logo) //Small Icon from drawable 
      .setContentTitle(this.getString(R.string.app_name)) 
      .setContentText(notificationMessage) 
      .setAutoCancel(true) 
      .setLocalOnly(true) 
      .setColor(this.getResources().getColor(R.color.green)) 
      .setStyle(
        new android.support.v4.app.NotificationCompat.BigTextStyle().bigText(notificationMessage)) 

// .setLargeIcon( // BitmapFactory.decodeResource(this.getResources()、 // R/Drawable.ic_launcher))//描画可能なビッグアイコン .setContentIntent(pendingIntent);

notificationBuilder.setPriority(Notification.PRIORITY_HIGH); 
    notificationBuilder.setDefaults(Notification.DEFAULT_SOUND); 
    notificationBuilder.setVibrate(new long[]{0, 100, 200, 300}); 

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

    notificationManager.notify(not_nu, notificationBuilder.build()); 
} 

public static int generateRandom() { 
    Random random = new Random(); 
    return random.nextInt(9999 - 1000) + 1000; 
} 

`

0

そのアンドロイドLから知られている問題のロリポップ下のメソッドを使用する場合、何をしなければならないことは非常に簡単

チェックデバイスのOSの実行時バージョンと

です

上記のLollipopが新しいシルエットアイコンを作成し、あなたの notificationbig_iconの代わりに使用する場合は、それ以外の場合
関連する問題