請分享如何在doinbackground()或onpostexecute()方法中使用意圖Asynctask類。當我嘗試使用這些代碼時,它顯示錯誤。如何在Asynctask類中使用意圖?
Intent intent = new Intent(asynctask.this, home.class);
startActivity(intent);
finish();
private Class<Home> clazz;
public asynctask(Class<Home> clazz){
this.clazz = clazz;
}
的AsyncTask doInBackground()方法:
protected Void doInBackground(Void... arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(this, clazz);
startActivity(intent);
finish();
Toast.makeText(cxt, "welcome", Toast.LENGTH_SHORT).show();
return null;
}
'asynctask'您的活動? – Rustam 2014-10-09 11:27:51
你必須總是在onPostExecute()方法中使用intent ..並且不要在doInBackground()中使用toast,Toast應該可能是它在你的代碼中給出錯誤,並且會發布你的logcat .. – 2014-10-09 11:28:26
請清楚地告訴我新的android我不知道有關asynctask類的功能。 – 2014-10-09 11:28:49