Android starts the activity anonymously and starts the system activity
Generally, when we use Intent for activity jump, we all know the name of the activity to jump to, for example:
Intent intent=new Intent(FirstActivity.this,SecondActitivy.class);startActivity(intent);
When SecondActitivy. class and FirstActivity are no longer the same App, we need to use anonymous startup,
Start anonymously:
First, you need to set the xml configuration file of the started SecondActivity:
FirstActivity can be used
To find SecondActivity
The FirstActivity code is as follows:
Intent intent=new Intent();intent.setAction("toSecondPage");startActivity(intent);
In this way, you can adjust the ActionName to an Activity that is not in the App.
The system activity is also started as follows:
The ActionName provided by a system is used to jump to the system Activity, and some messages can be appended. (xml is four 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 the Baidu homepage intent. setAction (Intent. ACTION_VIEW); Uri uri = Uri. parse ("http://www.baidu.com"); intent. setData (uri);} else if (v. equals (toPicButton) {// open the system image intent. setAction (Intent. ACTION_GET_CONTENT); intent. setType ("image/*"); // open all the images. if you need to obtain the image, you need to write the callback function} else if (v. equals (toMesButton) {// sends the message intent. setAction (Intent. ACTION_SEND); intent. setType ("text/plain"); intent. putExtra (Intent. EXTRA_TEXT, "this is my first message like this");} else if (v. equals (toPhoneButton) {// call intent. setAction (Intent. ACTION_VIEW); Uri uri = Uri. parse ("tel: 1839860592"); intent. setData (uri) ;}startactivity (intent );}}