06-09 17:15:08.880: W/dalvikvm(3568): threadid=1: thread exiting with uncaught exception (group=0x2aac0560)
06-09 17:15:08.880: E/AndroidRuntime(3568): FATAL EXCEPTION: main
06-09 17:15:08.880: E/AndroidRuntime(3568): android.app.RemoteServiceException: Bad notification posted from package com.ozing.appstore: Couldn't expand RemoteViews for: StatusBarNotification(package=com.ozing.appstore id=1 tag=null notification=Notification(vibrate=null,sound=null,defaults=0x0,flags=0x11))
06-09 17:15:08.880: E/AndroidRuntime(3568):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1044)
06-09 17:15:08.880: E/AndroidRuntime(3568):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 17:15:08.880: E/AndroidRuntime(3568):  at android.os.Looper.loop(Looper.java:130)
06-09 17:15:08.880: E/AndroidRuntime(3568):  at android.app.ActivityThread.main(ActivityThread.java:3686)
06-09 17:15:08.880: E/AndroidRuntime(3568):  at java.lang.reflect.Method.invokeNative(Native Method)
06-09 17:15:08.880: E/AndroidRuntime(3568):  at java.lang.reflect.Method.invoke(Method.java:507)
06-09 17:15:08.880: E/AndroidRuntime(3568):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-09 17:15:08.880: E/AndroidRuntime(3568):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-09 17:15:08.880: E/AndroidRuntime(3568):  at dalvik.system.NativeStart.main(Native Method)

解决方案 »

  1.   

    /**
     * 通知管理
     */
    public void statusNotifi() { //com.ozing.appstore.activity.MyAppsActivity
    // Intent mIntent = new Intent(mContext, MyAppsActivity.class); try {
    Intent mIntent = new Intent();
    mIntent.setAction(Intent.ACTION_VIEW); mIntent.setComponent(new ComponentName("com.ozing.appstore",
    "com.ozing.appstore.activity.MyAppsActivity")); // 这里需要设置Intent.FLAG_ACTIVITY_NEW_TASK属性
    mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent mContentIntent = PendingIntent.getActivity(mContext, 0,
    mIntent, 0);
    mNotification.contentView = new RemoteViews(mContext.getPackageName(),
    R.layout.my_status_service); //app ico image
    mNotification.contentView.setImageViewResource(R.id.status_icon,
    R.drawable.appstoresface0401);
    //app noti
    mNotification.contentView.setTextViewText(R.id.status_text, "你有"
    + updateNum + "个应用需要更新!");
    //app names
    String appNames = strName.toString();
    int nameLens = MyUtils.getStrLength(appNames);
    if (nameLens >= 30){
    appNames = MyTools.splitString(appNames, 30, "...");
    }
    mNotification.contentView.setTextViewText(R.id.status_appnames,
    appNames );
    //设置时间
    SimpleDateFormat sDateFormat = new SimpleDateFormat("MM-dd  hh:mm");
    String date = sDateFormat.format(new java.util.Date());
    mNotification.contentView.setTextViewText(R.id.status_times, date+" >"); // 添加led
    mNotification.ledARGB = Color.BLUE;
    mNotification.ledOffMS = 0;
    mNotification.ledOnMS = 1;
    mNotification.flags |= Notification.FLAG_SHOW_LIGHTS;
    mNotification.flags |= Notification.FLAG_AUTO_CANCEL;
    // 手动设置contentView属于时,必须同时也设置contentIntent不然会报错
    mNotification.contentIntent = mContentIntent;
    // 触发通知(消息ID,通知对象)
    mNotificationManager.notify(NOTIFICATION_ID, mNotification);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    case CHECK_NET: if (updateNum == 0) {
    try {
    statusNotifi();   // -----》》》》》调用这里的时候问题出现无法捕捉到异常
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    } else{
    statusNotifi();// 发送通知更新情况
    stopSelf();
    }
    break;
      

  2.   

    /**
    * 通知管理
    */
    public void statusNotifi() {//com.ozing.appstore.activity.MyAppsActivity
    //  Intent mIntent = new Intent(mContext, MyAppsActivity.class);try {
    Intent mIntent = new Intent();
    mIntent.setAction(Intent.ACTION_VIEW);mIntent.setComponent(new ComponentName("com.ozing.appstore",
    "com.ozing.appstore.activity.MyAppsActivity"));// 这里需要设置Intent.FLAG_ACTIVITY_NEW_TASK属性
    mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent mContentIntent = PendingIntent.getActivity(mContext, 0,
    mIntent, 0);
    mNotification.contentView = new RemoteViews(mContext.getPackageName(),
    R.layout.my_status_service);//app ico image
    mNotification.contentView.setImageViewResource(R.id.status_icon,
    R.drawable.appstoresface0401);
    //app noti
    mNotification.contentView.setTextViewText(R.id.status_text, "你有"
    + updateNum + "个应用需要更新!");
    //app names
    String appNames = strName.toString();
    int nameLens = MyUtils.getStrLength(appNames);
    if (nameLens >= 30){
    appNames = MyTools.splitString(appNames, 30, "...");
    }
    mNotification.contentView.setTextViewText(R.id.status_appnames,
    appNames );
    //设置时间
    SimpleDateFormat sDateFormat = new SimpleDateFormat("MM-dd hh:mm");
    String date = sDateFormat.format(new java.util.Date());
    mNotification.contentView.setTextViewText(R.id.status_times, date+" >");// 添加led
    mNotification.ledARGB = Color.BLUE;
    mNotification.ledOffMS = 0;
    mNotification.ledOnMS = 1;
    mNotification.flags |= Notification.FLAG_SHOW_LIGHTS;
    mNotification.flags |= Notification.FLAG_AUTO_CANCEL;
    // 手动设置contentView属于时,必须同时也设置contentIntent不然会报错
    mNotification.contentIntent = mContentIntent;
    // 触发通知(消息ID,通知对象)
    mNotificationManager.notify(NOTIFICATION_ID, mNotification);
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    case CHECK_NET:if (updateNum == 0) {
    try {
    statusNotifi(); // -----》》》》》调用这里的时候问题出现无法捕捉到异常
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    } else{
    statusNotifi();// 发送通知更新情况
    stopSelf();
    }
    break;
      

  3.   

    应该是你的R.layout.my_status_service 这个layout中使用了RemoteViews不支持的组件
    在RemoteViews这种调用方式中,你只能使用以下几种界面组件:
    Layout:
        FrameLayout, LinearLayout, RelativeLayoutComponent:
      AnalogClock, Button, Chronometer, ImageButton, ImageView, ProgressBar, TextView, ViewFlipper, ListView, GridView, StackView, AdapterViewFlipper
      

  4.   

    请参考:
    http://developer.android.com/guide/topics/appwidgets/index.html#CreatingLayout