Thursday, November 28, 2013

How to have a getStringExtra message before onCreate method? [android help]


How to have a getStringExtra message before onCreate method?


java - How to have a getStringExtra message before onCreate method? - Stack Overflow







Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
















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?



















lang-java






Read more

stackoverflow.comm



No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...