I have one App that uses Google maps, I am trying to get Duration data by fetching JSON data through AsyncTask...and testing it on my Tab...
The AsyncTask is not working and executing here...
With some search i get to know that AsyncTask do not work proper in 4.0.4 so u better to use runnable instead of AsyncTask
Now here i dont have any idea of runnable or handler and all...
please help me how and where and what i have to code to work my 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();
}
}
}
right now i am just implimenting simple code, but its not giving output