Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
998 views
in Technique[技术] by (71.8m points)

google cloud messaging - Android NotificationManager giving me "no valid small icon" error

I am having a strange error with notification manager.

@Override
public void onMessageReceived(String from, Bundle data)
{
     Log.i(TAG, "IP : " + (String) data.get("ip"));
     NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
     Intent acceptNextIntent = new Intent(MainActivity.BROADCAST_KEY_ACCEPT);
//        acceptNextIntent.putExtra("ip", (String) data.get("blah")); //add stuff here
     PendingIntent acceptNextPendingIntent = PendingIntent.getBroadcast(this, 0, acceptNextIntent, 0);

     Intent declineNextIntent = new Intent(MainActivity.BROADCAST_KEY_DECLINE);
     PendingIntent declineNextPendingIntent = PendingIntent.getBroadcast(this, 0, declineNextIntent, 0);

     NotificationCompat.Action acceptAction = new NotificationCompat.Action
                .Builder(R.drawable.common_signin_btn_icon_disabled_focus_light, "Grant Request", acceptNextPendingIntent).build();

     NotificationCompat.Action declineAction = new NotificationCompat.Action
                .Builder(R.drawable.common_signin_btn_icon_focus_dark, "Decline Request", declineNextPendingIntent).build();

     NotificationCompat.Builder notification = new NotificationCompat.Builder(this)
                .setContentTitle("New Password Request From " + (String) data.get("ip"))
                .addAction(acceptAction)
                .addAction(declineAction);

     notificationManager.notify(1, notification.build()); //ERROR HERE

Error Message:

9.474 9327-9371/com.inh.amnesia_application I/MyGcmListenerService: IP : 128.239.213.39
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime: Process: com.inh.amnesia_application, PID: 9327
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime: java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(pri=0 contentView=com.inh.amnesia_application/0x1090085 vibrate=null sound=null defaults=0x0 flags=0x0 color=0x00000000 actions=2 vis=PRIVATE)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at android.app.NotificationManager.notify(NotificationManager.java:222)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at android.app.NotificationManager.notify(NotificationManager.java:194)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at com.inh.amnesia_application.MyGcmListenerService.onMessageReceived(MyGcmListenerService.java:65)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService.zzt(Unknown Source)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService.zzk(Unknown Source)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
11-10 19:49:59.477 9327-9371/com.inh.amnesia_application E/AndroidRuntime:     at java.lang.Thread.run(Thread.java:818)

Does this mean that the icons I am trying to access does not exist? I am not sure how to interpret this error and searching this error message does not yield anything.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...