Problem: Now the activity uses Viewpager,viewpager ' element is fragment, the activity as the result of Startactivityforresult, so at the end of the need to pass the current information to the former intent, This includes variables in the instance of the current fragment.
Description: This method, in which the activity obtains only one class, but does not have the user interaction changes the fragment variable
Willfragment fragment= (willfragment) Madapter.getitem (Mviewpager.getcurrentitem ());
Solve:
Activity code, receive fragment pass message:
private Handler Handler; private Intent Backintent; ... setHandler ( new Handler ( New Callback () {@Override public boolean Handlemessage (Message Message) { // TODO auto-generated Method stub Backintent= (Intent) message.obj; return false ; } }));
The corresponding fragment code, which transmits a message to the activity:
New== (willactivity) getactivity (); Willactivity.gethandler (). SendMessage (message);
Done
Interaction between activity and fragment--handler