工作我有一個使用谷歌地圖一個應用,我想通過獲取的AsyncTask JSON數據......和我的選項卡進行測試以獲得持續的數據...的AsyncTask不在4.0.4
該的AsyncTask不工作,在這裏執行...
有了一些搜索我到知道的AsyncTask不正確4.0.4工作,這樣你們更好地使用可運行的,而不是的AsyncTask
現在,這裏我不有任何runnable或處理器和所有的想法...
請幫助我如何以及在哪裏以及如何使用我的AsyncTask來編寫代碼?
public class Map extends Activity {
GoogleMap mMap;
String duration,distance,url,s;
StringBuilder data = null;
InputStream is = null;
JSONObject jObj = null;
String json = "";
ProgressDialog pd;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
//Toast.makeText(getApplicationContext(), "Cant connect to google play service", 10).show();
MapFragment fa = (MapFragment) getFragmentManager().findFragmentById(R.id.fragment1);
mMap = fa.getMap();
new dis().execute();
//Toast.makeText(getApplicationContext(), duration, 10).show();
}
public class dis extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... arg0) {
// TODO Auto-generated method stub
try{
Toast.makeText(getApplicationContext(), "jinal", 10).show();
}catch(Exception e){}
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
pd.dismiss();
Toast.makeText(getApplicationContext(), "jinal", 10).show();
super.onPostExecute(result);
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
pd = new ProgressDialog(Map.this);
pd.setTitle("Please Wait....");
pd.setMessage("Wait");
pd.setCancelable(false);
pd.show();
}
}
}
現在我只是implimenting簡單的代碼,但它不是給輸出
我不知道你在哪裏得到的想法或者正是你的「的AsyncTask不工作是什麼意思適當的4.0.4" ,但如果你發佈相關的代碼,我們或許可以幫助你 – codeMagic 2015-02-06 17:42:02
發佈你現在所擁有的 – Psypher 2015-02-06 17:42:54
的代碼的AsyncTask http://stackoverflow.com/questions/12839384/asynctask-doinbackground-not-called-在Android平板電腦 – Jinal 2015-02-06 17:52:06