Android通知错误

时间:2016-07-27 17:34:01

标签: android

我已经创建了一个通知,但是它给出了错误。我无法追踪问题,在支持自定义通知的android documentation组件中看到,一切正常。有没有人知道这个问题?

    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)

我的通知是:

   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;
    }

我的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>

0 个答案:

没有答案