I have two activities which in the first one I make a message and by putExtra
I move it to next activity. But as you know to get the message in the secind activity I need to have getStringExtra
in onCreate
method. In the other hand I really need to have that message before onCreate starts. So how can I have that.
public class Result extends Activity {
String url; // <<< I need the message to put it here
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_result);
Intent intent = getIntent();
String mainURL = intent.getStringExtra(SingleSearchPage.EXTRA_MESSAGE); // Here is the message
url = mainURL; //Tried to change the value of URL but did not work
new GetJSONTask().execute(url);
}
class GetJSONTask extends AsyncTask {
protected JSONObject doInBackground(String... urls) {
// Creating new JSON Parser
JSONParser jParser = new JSONParser();
// Getting JSON from URL
JSONObject json = jParser.getJSONFromUrl(url);
return json;
}
Any idea to have the value of intent message before the onCreate?