Bad notification Android

0

I have created a notification but it is giving error. I can not track down the problem, seen in android documentation components that support for custom notification and everything is ok. Does anyone have any idea of the problem?

    Process: sample.rio360app, PID: 11266
android.app.RemoteServiceException: Bad notification posted from package sample.rio360app: Couldn't expand RemoteViews for: StatusBarNotification(pkg=sample.rio360app user=UserHandle{0} id=1 tag=null score=0 key=0|sample.rio360app|1|null|10183: Notification(pri=0 contentView=sample.rio360app/0x7f0c0054 vibrate=null sound=null defaults=0x0        flags=0x10 color=0x00000000 vis=PRIVATE secFlags=0x0 secPriority=0))
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2020)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7229)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

My notifications is that:

   public RemoteViews createCustomNotification() {


        notificationView = new RemoteViews(context.getPackageName(), R.id.download_progress);
        builder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.ic_launcher)
                .setAutoCancel(true)
                .setContent(notificationView);

        // Create Notification Manager
        NotificationManager notificationmanager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        //Build Notification with Notification Manager
        notificationmanager.notify(NOTIFICATION_ID, builder.build());

        return notificationView;
    }

My notification.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp">


    <ImageView
        android:id="@+id/ic_notification"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

    <ProgressBar
        android:id="@+id/download_progress"
        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
        android:layout_width="220dp"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/ic_notification"
        android:layout_alignStart="@+id/title_notification" />


    <TextView
        android:id="@+id/title_notification"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/download_progress"
        android:layout_marginBottom="15dp"
        android:layout_marginStart="50dp"
        android:text="Tomar cahcaƧa na lapa!" />

    <ImageButton
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@android:drawable/ic_media_play"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true" />
</RelativeLayout>
android
view
notifications
asked on Stack Overflow Jul 27, 2016 by Douglas Mesquita • edited Dec 19, 2019 by Subhanshuja

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0