Last active
August 29, 2015 14:19
-
-
Save markcerqueira/aa118d6e9049f73f6a05 to your computer and use it in GitHub Desktop.
Why!?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends ActionBarActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main_activity); | |
doWork("string_param"); | |
} | |
// Note the parameter variable name (i.e. string) | |
private void doWork(final String string) { | |
AsyncTask<Void, Void, String> asyncTask = new AsyncTask<Void, Void, String>() { | |
@Override | |
protected String doInBackground(Void... params) { | |
return "string_async_task"; | |
} | |
@Override | |
protected void onPostExecute(String resultString) { | |
// Why is this allowed? If I leave this as is, the log below | |
// prints "string_async_task". If I comment this line out, it | |
// prints "string_param" | |
String string = resultString; | |
Log.e("MainActivity", string); | |
} | |
}; | |
asyncTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// class file decoded using JD-GUI (http://jd.benow.ca/) | |
public class MainActivity extends ActionBarActivity | |
{ | |
protected void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
setContentView(2130968599); | |
doWork("string_param"); | |
} | |
private void doWork(String string) | |
{ | |
AsyncTask<Void, Void, String> asyncTask = new AsyncTask() | |
{ | |
protected String doInBackground(Void... params) | |
{ | |
return "string_async_task"; | |
} | |
protected void onPostExecute(String resultString) | |
{ | |
String string = resultString; | |
Log.e("MainActivity", string); | |
} | |
}; | |
asyncTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, new Void[0]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// class file decoded using JD-GUI (http://jd.benow.ca/) | |
class MainActivityActivity$1 extends AsyncTask<Void, Void, String> | |
{ | |
MainActivityActivity$1(MainActivityActivity paramMainActivityActivity) {} | |
protected String doInBackground(Void... params) | |
{ | |
return "string_returned_by_async_task"; | |
} | |
protected void onPostExecute(String resultString) | |
{ | |
String string = resultString; | |
Log.e("MainActivity", "paramString = " + string); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment