当我启用系统实例化接收器以显示来自其onclick的通知信息时,显示对话应用程序无响应的应用程序。
logcat的:
D/ANRAppManager: !!! It is not under singleton mode, U can't use it. !!!
03-18 17:13:18.593 24690-24726/com.systechdigital.dashboardnotification W/Binder: Caught a RuntimeException from the binder stub implementation.
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder com.mediatek.anrappmanager.IFrameworks.serviceManagerGetService(java.lang.String)' on a null object reference
at com.mediatek.anrappmanager.ANRManagerNative$1.b(SourceFile:77)
at com.mediatek.anrappmanager.ANRManagerNative$1.c(SourceFile:75)
at com.mediatek.anrappmanager.ANRManagerNative$a.get(SourceFile:97)
at com.mediatek.anrappmanager.ANRManagerNative.getDefault(SourceFile:35)
at com.mediatek.anrappmanager.ANRAppManager.dumpMessageHistory(SourceFile:59)
at android.app.ActivityThread$ApplicationThread.dumpMessageHistory(ActivityThread.java:1244)
at android.app.ApplicationThreadNative.onTransact(ApplicationThreadNative.java:682)
at android.os.Binder.execTransact(Binder.java:451)
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'android.os.IBinder com.mediatek.anrappmanager.IFrameworks.serviceManagerGetService(java.lang.String)' on a null object reference
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: at com.mediatek.anrappmanager.ANRManagerNative$1.b(SourceFile:77)
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: at com.mediatek.anrappmanager.ANRManagerNative$1.c(SourceFile:75)
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: at com.mediatek.anrappmanager.ANRManagerNative$a.get(SourceFile:97)
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: at com.mediatek.anrappmanager.ANRManagerNative.getDefault(SourceFile:35)
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: at com.mediatek.anrappmanager.ANRAppManager.dumpMessageHistory(SourceFile:59)
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: at android.app.ActivityThread$ApplicationThread.dumpMessageHistory(ActivityThread.java:1244)
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: at android.app.ApplicationThreadNative.onTransact(ApplicationThreadNative.java:682)
03-18 17:13:18.594 24690-24726/com.systechdigital.dashboardnotification W/System.err: at android.os.Binder.execTransact(Binder.java:451)
清单:
<service
android:name=".ServiceClass"
android:exported="false" />
<activity android:name=".NotificationActivity" />
<receiver
android:name=".BroadCastReceiverClass"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="Notification" />
</intent-filter>
</receiver>
receiverClass:
if(result!=null) {
intent = new Intent(context, NotificationActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("NotificationList", result);
context.startActivity(intent);
}
这里从服务中的asynctask发送通知:
if (result != null) {
//notification
NotificationCompat.Builder notification=new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.systech_logo)
.setContentTitle("Notification")
.setContentText("Delivered")
.setAutoCancel(true)
;
intent1 = new Intent(context, BroadCastReceiverClass.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent1.setAction("Notification");
context.sendBroadcast(intent1);
Intent notificationActivityIntent=new Intent(context,NotificationActivity.class);
notificationActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(notificationActivityIntent);
intent1.putExtra("Result",result);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent1);
TaskStackBuilder taskStackBuilder=TaskStackBuilder.create(context);
taskStackBuilder.addParentStack(NotificationActivity.class);
taskStackBuilder.addNextIntent(intent1);
// PendingIntent pendingIntent=taskStackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent=PendingIntent.getBroadcast(context,0,intent1,PendingIntent.FLAG_CANCEL_CURRENT);
notification.setContentIntent(pendingIntent);
NotificationManager notificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notification.build());
}
你可以找我找出我的错误。