Android intent on two pages there are two main values, one is to pass values between two activity, and the other is to pass data between a normal page and an activity.
1. Intent values between two activity
first define two activity firstactivity and secondactivity
Code in the OnCreate () method of firstactivity
Intent Intent = new Intent ();
String str = "Data to be passed";
Intent.putextra ("str", str);
Intent.setclass (firstactivity. this, secondactivity.class);
StartActivity (Intent);
In the Secondactivity page
Intent Intent = Getintent ();
Intent.getstringextra ("str");
2. Intent passing data between a normal page and an activity
two pages of mainactivity and Intention.java respectively
Code in the OnCreate () method of mainactivity
Intent Intent = new Intent ();
String str = "Data to be passed";
Intent.putextra ("str", str);
Intent.setclass (context, secondactivity.class);
Context. startactivity (intent);
The code in Intention.java is
Intent Intent = Getintent ();
Intent.getstringextra ("str");
Original address: http://www.bkjia.com/qtjc/614274.html
Intent on Android Two page value problem