We generally know the name of the activity that needs to jump when we use intent for activity jumps, for example:
Intent intent=new Intent (firstactivity.this,secondactitivy.class); startactivity (Intent);
WhenSecondactitivy.classand firstactivity no longer the same app, we need to use the anonymous boot,
Anonymous boot:
You first need to set the XML configuration file for the secondactivity that is started:
<activity android:name= "Testintent.secondactitivy" > <intent-filter> <action android:name= "Tosecondpage"/> <category android:name= "Android.intent.category.DEFAULT"/> </intent-filter > </activity>
Firstactivity can use<action android:name= "Tosecondpage"/>
To find secondactivity.
The firstactivity code is as follows:
<span style= "White-space:pre" ></span>intent intent=new Intent (); Intent.setaction ("ToSecondPage"); StartActivity (Intent);
This allows you to use ActionName to transfer activity to a non-app
Starting the system activity is also implemented as follows:
A system-provided actionname to jump to the activity of the system while appending some messages; (XML is 4 simple buttons)
Package Testintent;import Java.net.url;import Android.app.activity;import android.content.intent;import Android.net.uri;import Android.os.bundle;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.button;import Com.example.androidtest.r;public class Firstactivity extends Activity implements Onclicklistener{private button towebbutton;private button topicbutton;private button tomesbutton;private button Tophonebutton; @Overrideprotected void OnCreate (Bundle savedinstancestate) {//TODO auto-generated method Stubsuper.oncreate (savedinstancestate); Setcontentview (R.layout.first_activity_main); toWeBButton= (Button) Findviewbyid (R.id.toweb); topicbutton= (Button) Findviewbyid (r.id.topic); tomesbutton= (button) Findviewbyid ( R.id.tomes); tophonebutton= (Button) Findviewbyid (R.id.tophone); Towebbutton.setonclicklistener (this); Topicbutton.setonclicklistener (This), Tomesbutton.setonclicklistener (this); Tophonebutton.setonclicklistener ( this);} @Overridepublic void OnClick (VieW v) {//TODO auto-generated method Stubintent intent=new Intent (); if (V.equals (Towebbutton)) {//Jump to Web page Baidu Home Intent.setaction (Intent.action_view); Uri Uri=uri.parse ("http://www.baidu.com"); Intent.setdata (URI);} else if (v.equals (Topicbutton)) {//Open system Picture intent.setaction (Intent.action_get_content); Intent.settype ("image/*");// Open all the pictures, if need to get the picture need write callback function}else if (v.equals (Tomesbutton)) {//Send message intent.setaction (intent.action_send); Intent.settype ("Text/plain"); Intent.putextra (Intent.extra_text, "This is the first time I've sent this message");} else if (v.equals (Tophonebutton)) {//Call intent.setaction (Intent.action_view); Uri Uri=uri.parse ("tel:1839860592"); Intent.setdata (URI);} StartActivity (intent);}}
Android Anonymous start Activity start system activity