Thursday, April 24, 2014

Android intent pass data


posts by u013769695 on 2014-04-18 17:05:05 Edit
Android application which has multiple threads, how do I define String info in the info passed to another Acticity in the main Activity inside a thread, I have tried various methods of intent, always being null pointer exception, humbly ask for advice, I a little rookie, seeking to learn! ! ! ! !
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
You have to pass a value of simple practices ah, the definition of a class which has a static string field to hold the thread operate this static property in any activity where direct access on the line
Reply:
Notify ui handler to pass values
Reply:
2L can point you in detail, talking a little fuzzy
Reply:
3L I do not pass through the UI directly within the program pass, the relationship does not occur with the UI
Reply:
cited landlord u013769695 reply:
Android program there are multiple threads, how to define String info in the info passed in the main Activity inside a thread to another Acticity, I tried a variety of methods intent, always being null pointer exception, humbly ask for advice, I a little rookie, seeking to learn! ! ! ! !


You should not be in the child threads started directly inside other Activity, right? Should be to return to the UI thread and then start another activity, right? Then define an intent, you can put any kind of value, ah, then you want to start the activity of oncreate Lane, getintent () and then get the corresponding key, you can get to the data you pass over the ah
Reply:
Intent is certainly possible, write your own is definitely a problem.


cited a floor abcmsnet reply:
you want to pass a value of simple practices ah, the definition of a class which has a static string field to store, manipulate this thread static properties, in any activity where direct access on the line


Said means setting static variables inside a class, in other classes directly referenced by the class name.
Reply:
Learning about learning about learning about
Reply:
In the first Activity, the assignment to the String type name.
[((ListView) v). GetAdapter (). GetItem (oldPosition). ToString ()] The actual components according to your own to get, just to give an example.
Intent intent = new Intent ();
intent.setClass (MainActivity.this, DetailActivity.class);
intent.putExtra ("name", ((ListView) v) getAdapter () getItem (oldPosition) toString ()...);
startActivity (intent);

Get the name in the second.
Intent intent = this.getIntent ();
name = intent.getStringExtra ("name");

No comments:

Post a Comment