Android Development: Explicit/implicit intent intent Jump activity Summary

Source: Internet
Author: User

an explicit jump

is a common method of jumping in cases where the package name and class name are known:

Intent mintent = new Intent () mintent.setclassname ("Com.android.settings", "com.android.settings.Settings"); Mcontext.startactivity (mintent);

We used to do the same thing:

Intent Intent = new Intent (Mcontext, Xxactivity.class); startactivity (Intent);
This is a jump to the current application of an activity, I believe we are very familiar with, today is mainly about how to use the implicit intent intent to jump
Implicit Jump1, the implicit jump action jumpIt is assumed that an activity is declared in the manifest:
   <activity android:name= ". Actionactivity ";         <intent-filter            Action android:name= "Customer_action_here"        </intent-filter>    </activity >

then we can use the following code to jump to the above activity:
    Create an implicit Intent object: Action action    Intent Intent = new Intent ();    Set Intent action to the action    intent.setaction ("Customer_action_here") specified in the list;    StartActivity (Intent);

2, the category of the implicit jump jumpSuppose an activity is declared like this in the list:
        <activity android:name= ". Categoryactivity ">            <intent-filter>                <action android:name=" Customer_action_here "/>                <category android:name= "Customer_category_here"/>            </intent-filter>        </activity>

we can use the following code to jump to the above activity:
Create an implicit Intent object: Category class Intent Intent = new Intent (); Intent.setaction ("Customer_action_here"); Add the same custom category Intent.addcategory as the list ("Customer_category_here"); StartActivity (Intent);

3. Data jump of implicit jumpIt is assumed that an activity is defined as:
< activity android:name= ". Dataactivity ">     < intent-filter>         < category android:name=" Android.intent.category.DEFAULT "/ >         < data             android:scheme= "content"             android:host= "Com.example.intentdemo"             android:port= " 8080 "             android:pathpattern=". *pdf "             android:mimetype=" Text/plain "/>     </intent-filter> </ Activity>

we can use the following code to jump:
Create an implicit Intent object, method four: Date data Intent Intent = new Intent (); Uri uri = uri.parse ("Content://com.example.intentdemo:8080/abc.pdf"); Note: SetData, Setdataandtype, SetType these three methods can only be used alone, not shared                //alone in the SetData method set URI//intent.setdata (URI);//separate with Setype Method Set Type//intent.settype ("Text/plain"); The above step setting is incorrect, either by setting the URI with the Setdataandtype method and the MIME type Intent.setdataandtype (URI, "Text/plain"); StartActivity (Intent);

The daport in the list and the following attributes are optional, not necessarily added, but the port and the following attributes are added, in the Java code in the URI to do a corresponding match.
4. Application of implicit jump calling system4.1 Browsing Web pages using a browser
Web browser Uri uri= uri.parse ("http://www.baidu.com"); Intent Intent = new Intent (Intent.action_view, URI); StartActivity (Intent);
4.2 Calling the map
Open the map to view the latitude and longitude uri uri = uri.parse ("geo:38.899533,-77.036476"); Intent Intent = new Intent (Intent.action_view, URI); StartActivity (Intent);

4.3 calling phone dialing (no dial-up permission required)
    Uri uri = uri.parse ("tel:10086");    Intent Intent = new Intent (intent.action_dial, URI);//attention differs from the following 4.4 ACTION    startactivity (Intent);
4.4 Call Direct dialing (requires dial-up permission)
    Uri uri = uri.parse ("tel:15980665805");    Intent Intent = new Intent (Intent.action_call, URI);//Note differences from the above 4.3 Aciton    startactivity (Intent);

4.5 Call SMS program (no need to send SMS permission, the recipient to fill)
    Intent Intent = new Intent (intent.action_view);        Intent.putextra ("Sms_body", "Write text Here");        Intent.settype ("vnd.android-dir/mms-sms");        StartActivity (Intent);
4.6 Call SMS program (no need to send SMS permission)
    Uri uri = uri.parse ("smsto:10086");//Specify receiver    Intent Intent = new Intent (intent.action_sendto, URI);    Intent.putextra ("Sms_body", "You this black-hearted operator");    StartActivity (Intent);
4.7 Calling a mail program
    Intent Intent = new Intent (intent.action_sendto);     Intent.setdata (Uri.parse ("Mailto:[email protected]");     Intent.putextra (Intent.extra_subject, "This is the title");     Intent.putextra (Intent.extra_text, "This is the content");     StartActivity (Intent);

4.8 Calling Media Player
    Intent Intent = new Intent (intent.action_view);    Uri uri = uri.parse ("File:///sdcard/zhy.mp3");    Uri uri = uri.parse ("File:///sdcard/a.mp3");    Intent.setdataandtype (URI, "Audio/mp3");    StartActivity (Intent);

4.9 Call Search
    Intent Intent = new Intent ();     Intent.setaction (intent.action_web_search);     Intent.putextra (Searchmanager.query, "Android");     StartActivity (Intent);

SummaryI believe that everyone through the above introduction, has been to intent jump has a relatively mature understanding, intent is the link between components, use it can let the system for us to do a lot of work, do not need us to specify the completion of the process. In fact, we will find that the call system program using liquid is nothing more than an implicit jump, but the use of the system is built in some action,uri,data and other information. We hope to help you. Reprint please indicate the source and link: http://blog.csdn.net/xiong_it/article/details/45071809This article is theAndroid Development: How to hide your app"sequel, interested friends can view.




Android Development: Explicit/implicit intent intent Jump activity Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.