我收到了应用用户的以下报告:
class java.lang.RuntimeException
Msg: android.os.AsyncTask$3.done:200 (An error occured while executing doInBackground())
我唯一能做的就是导致错误,试图在遇到错误时触发状态栏通知。我可以在doInBackground()
方法中执行此操作,还是只能在onPostExecute()
方法中执行此操作?
这里有一些代码......
在我的doInBackground()
方法中,我在catch
块的try/catch
部分调用了以下函数:
private void triggerNotification(String contentText) {
mNotificationManager = (NotificationManager) thisContext.getSystemService(ns);
if(contentText == null) {
contentText = "Sync complete.";
}
Intent notificationIntent = new Intent(thisContext, SomeOtherClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(thisContext, 0, notificationIntent, 0);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.setLatestEventInfo(thisContext, tickerText, contentText, contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, notification);
}