Action: A string constant that sets the action to be completed by intent. Use Setaction () to set the Action property and use Getaction () to get the Action property. You can either use the system's built-in action or define it yourself. System custom ACTION, such as Action_view, Action_edit, Action_main, and so on.
1. Custom Action
Specify an action constant in the androidmanifest.xml of the destination activity.
Copy Code code as follows:
<activity android:name= ". Actiondestination ">
<intent-filter>
<action android:name= "Skywang_action"/>
<category android:name= "Android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
The role of the <categoryandroid:name= "Android.intent.category.DEFAULT"/> is to illustrate that an implicit jump can be made by calling Setaction ("Skywang_ ACTION ") to find actiondestination this activity. In this way, other classes can jump to actiondestination through the following code. When you jump, the setaction string "skywang_action" must be consistent with the "skywang_action" defined in Androidmanifest.xml.
Copy Code code as follows:
Intent Intent = new Intent ();
Intent.setaction ("Skywang_action");
StartActivity (Intent);
2 system action
Copy Code code as follows:
Traffic Web page
URI Uri =uri.parse ("http://www.baidu.com");
Intent Intent = newintent (Intent.action_view, URI);
StartActivity (Intent);
Dial number
If you are want to use action_dial, your mustadd permissin in manifest, the permission is bellow
<uses-permissionandroid:name= "Android.permission.CALL_PHONE"/>
Uri uri = uri.parse ("tel:12580");
Intent it = new Intent (Intent.action_dial,uri);
StartActivity (IT);
Send SMS
Uri uri = uri.parse ("smsto:13410177756");
Intent it = newintent (Intent.action_sendto, URI);
It.putextra ("Sms_body", "thesms text");
StartActivity (IT);
Play mp3
Intent it = new Intent (Intent.action_view);
URI Uri =uri.parse ("File:///sdcard/song.mp3");
It.setdataandtype (URI, "Audio/mp3");
StartActivity (IT);