There are four kinds of intent common
1, first in the mainactivity to establish a button class B,
Then use Setcontentview (R.layout.activity_main) to find the button,
Let B = (Button) setcontentview (R.layout.activity_main);
Add Mouse events for B
B.setonclicklistener (this); To implement the implements Onclicklistener interface at this time
Implementing the OnClick method
public void OnClick (View v)
{
Definition Intent Intent = new intent ();
Intent.setclass (This,activity_01.class);
SetClass (Need a onclicklistener, at this time we inherit the interface so write this, need to jump class bytecode file with. class knot);
Last write Start method;
StartActivity (Intent);
}
2, public void OnClick (View v)
{
Definition Intent Intent = new intent ();
Intent.setclassname (This, "com.example.intentdemo.Activity_01");
Setclassname (this, requires a string to jump to the full class name of the activity);
Last write Start method;
StartActivity (Intent);
}
3,public void OnClick (View v)
{
Definition Intent Intent = new intent ();
Intent.setclassname ("com.example.activity", "activity.") Activity_01 ");
Setclassname (requires XML package name, to jump activity of the full class name);
If you want to jump to other non-main interface activity, you need to configure Android:exported= "true" in XML
The default value is False
Last write Start method;
StartActivity (Intent);
}
4,public void OnClick (View v)
{
Definition Intent Intent = new intent ();
Intent.setcomponent (New ComponentName (This,activity_01.class));
Intent.setcomponent (Requires ComponentName object, new one componentname required (this, byte code to jump));
Last write Start method;
StartActivity (Intent);
}
Intent four kinds of jumps