Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android notification - RemoteServiceException

I am getting RemoteServiceException. This occurs if I simply call the following in onResume() of the activity :

 NotificationManager mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);

        NotificationCompat.Builder notif = new NotificationCompat.Builder(mContext);
        notif.setTicker("Notification ticker")
             .setContentTitle("Vinceri")
             .setContentText("Ha recibido una oferta de trabajo")
             .setAutoCancel(true);
        //create notification from builder
        Notification notification = notif.build();
        mNotificationManager.notify(0, mBuilder.buildNotification(content));

It occurs only if notify is called.

android.app.RemoteServiceException: Bad notification posted from package com.java: Couldn't create icon: StatusBarIcon(pkg=com.java id=0x1 level=0 visible=true num=0 )
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1264)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4493)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
        at dalvik.system.NativeStart.main(Native Method)
like image 644
singhsumit Avatar asked Sep 20 '13 13:09

singhsumit


1 Answers

add this line in your code

notif.setSmallIcon(R.drawable.alarm);

make sure alarm icon should be on drawable folder

like image 109
Dinesh Raj Avatar answered Sep 16 '22 19:09

Dinesh Raj