android 自訂通知欄遇到的問題,android自訂

來源:互聯網
上載者:User

android 自訂通知欄遇到的問題,android自訂


首先看報錯資訊:

E/AndroidRuntime(12220): FATAL EXCEPTION: main

E/AndroidRuntime(12220): Process: gn.com.android.update, PID: 12220

E/AndroidRuntime(12220): android.app.RemoteServiceException: Bad notification posted from package gn.com.android.update: Couldn't expand RemoteViews for: StatusBarNotification(pkg=gn.com.android.update user=UserHandle{0} id=1 tag=null score=0 key=0|gn.com.android.update|1|null|10038: Notification(pri=0 contentView=gn.com.android.update/0x7f03000a vibrate=null sound=null defaults=0x0 flags=0x20 color=0x00000000 vis=PRIVATE))


E/AndroidRuntime(12220): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)

E/AndroidRuntime(12220): at android.os.Handler.dispatchMessage(Handler.java:106)


E/AndroidRuntime(12220): at android.os.Looper.loop(Looper.java:189)


E/AndroidRuntime(12220): at android.app.ActivityThread.main(ActivityThread.java:5532)


E/AndroidRuntime(12220): at java.lang.reflect.Method.invoke(Native Method)


E/AndroidRuntime(12220): at java.lang.reflect.Method.invoke(Method.java:372)


E/AndroidRuntime(12220): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)


E/AndroidRuntime(12220): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)



代碼如下:  

           通知欄定義布局中的一個控制項這樣寫的:

            <ImageView
        android:id="@+id/notificationImage"
        android:layout_width="@android:dimen/notification_large_icon_width"
        android:layout_height="@android:dimen/notification_large_icon_height"
        android:scaleType="center"
        android:clickable="true"
        android:background="@*android:drawable/notify_panel_notification_icon_bg_tile"
        android:src="@drawable/stat_sys_download_anim0" 
        />

                  

         java中代碼這樣:

        if (null == mNotification) {
            mContentIntent = PendingIntent.getActivity(this, 0, new Intent(this, SettingUpdate.class), 0);
            // new一個通知對象
            mNotification = new Notification(R.drawable.stat_sys_download_anim0,
                    getString(R.string.notify_auto_update_title), System.currentTimeMillis());
            mNotification.flags = Notification.FLAG_NO_CLEAR;
        }
        mNotification.icon = R.drawable.stat_sys_download_anim0;


       解決方案:

            把 android:src="@drawable/stat_sys_download_anim0" 這句話刪除掉,就沒有該問題了,就不報錯,但是顯示為黑色。初步估計是systemui問題, 現在不知道原因,請大神看到回複下,謝謝





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.