Component name, the first parameter is the package name of the application, and the latter is the main activity of the application
componentname com = new ComponentName ("Com.antroid.Test", "com.antroid.Test.TestActivity");
Intent Intent = new Intent ();
Set up Parts
Intent.setcomponent (COM);
StartActivity (Intent);
We can also use the following code to start the system's calendar program:
[JavaScript]
Intent intent=new Intent ();
Intent.setcomponent (New ComponentName ("Com.android.calendar", "com.android.calendar.LaunchActivity"));
StartActivity (Intent);
Intent intent=new Intent ();
Intent.setcomponent (New ComponentName ("Com.android.calendar", "com.android.calendar.LaunchActivity"));
StartActivity (Intent)
third :
turn from:/http www.eoeandroid.com/forum.php?mod=viewthread&tid=69600
The system provides a lot of activity that can be called directly, Can be called by the specified intent, such as open search:
- Intent Intent = new Intent (intent.action_web_search);
- Intent.putextra (Searchmanager.query, "searchstring")
- StartActivity (Intent);
Copy Code
Intent.action_web_search is a string that is the identity of the "search" activity, and extra is some data passed to the activity. After sending out this intent, the system knows what activity to invoke based on the ACTION string intent.action_web_search, and if there is a duplicate name, a selection dialog box pops up. Then open the activity and implement what you want to do.
So, how do we come to realize it ourselves.
First, write an activity, in the androidmanifest.xml inside the intent-filter, give this activity name:
- <intent-filter>
- <action android:name= "Chroya.foo"/>
- <category android:name= "Android.intent.category.DEFAULT"/>
- </intent-filter>
Copy Code
and then install. Once the installation is complete, you will find that the program is not found in the system. Don't worry, it's actually installed in the phone, but because he's not main, the system doesn't think of him as a application entry program.
And to open this activity, only the person who knows its name can. Use the same as the intent of the system. Its name is defined as "Chroya.foo", so it can be called with this string:
- Intent Intent = new Intent ("Chroya.foo");
- StartActivity (Intent);
Copy Code
The intent of the system that was just lifted shows that its activity uses getintent (). Getbundleextra (Searchmanager.query) to receive the passed in search string parameter. And this searchmanager.query is the key word. If you want to do this yourself, you just need to define the keyword and then take it from the Bundleextra.
Android-Launches another installed application or system program in one application (provided you know the main activity and package name of the application)