我是Android编程新手,在Java方面经验不足。
我在活动中加载带有webview的url,然后调用asynctask来解析url中的文本。解析后,我想通过通知将其发布到状态栏。在doInBackground之后,我将解析后的字符串传递给onPostExecute
但是有编译器错误。
谢谢,克雷格
protected void onPostExecute(String mycontent) {
// set up for notification in the notification status bar
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_stat_notify_lightning)
.setContentTitle("My Title Here")
.setContentText(mycontent);
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, WebViewActivity.class);
// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(WebViewActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent =
stackBuilder.getPendingIntent(
0,
PendingIntent.FLAG_UPDATE_CURRENT
);
mBuilder.setContentIntent(resultPendingIntent);
// Sets an ID for the notification
int mNotificationId = 001;
// Gets an instance of the NotificationManager service
NotificationManager mNotifyMgr =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Builds the notification and issues it.
mNotifyMgr.notify(mNotificationId, mBuilder.build());
}
答案 0 :(得分:0)
onPostExecute
之后将在主线程上自动调用 doInBackground
,你能告诉编译器错误的更多细节吗?