It's a lot of trouble to call another apk in an apk without looking at the school's instructional video, and sometimes it's scary to meet them, but after watching the Android development tutorial video, I think it's a simple thing to do. So write a small article for reference.
The system provides a lot of activity that can be called directly, which can be called by the specified intent, such as open search:
Java code
1. Intent Intent = new Intent (intent.action_web_search);
2. Intent.putextra (Searchmanager.query, "searchstring")
3. StartActivity (Intent);
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 of all, write an activity, in the androidmanifest.xml inside the intent-filter, give this activity named,
XML code
1. <intent-filter>
2. <action android:name= "Chroya.foo"/>
3. <category android:name= "Android.intent.category.DEFAULT"/>
4. </intent-filter>
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:
Java code
1. Intent Intent = new Intent ("Chroya.foo");
2. StartActivity (Intent);
I use the intent of the system I just lifted to show 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.
More Android Development tutorials at: Http://www.maiziedu.com/course/android/
Android Development Tutorial: Android Invoke Activity simple method