Android Learning-intent

Source: Internet
Author: User

Example 1

Define an activity's active,category, and call

Activity_main.xml

<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.zzzzzzzzz"Android:versioncode= "1"Android:versionname= "1.0" > <uses-SDK Android:minsdkversion= "16"android:targetsdkversion= "/>" <Application Android:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" > <Activity Android:name=". Mainactivity "Android:label= "@string/app_name" > <intent-filter> <action android:name= "Android.intent.action.MA In "/> <category android:name=" Android.intent.category.LAUNCHER "/> </intent-filter&        Gt </activity> <Activity Android:name=". Activity2 "Android:label= "@string/title_activity_activity2" > <intent-filter > <action android:name= "aaaaaaa AAAA "/> <action android:name=" bbbbbbbbbbbbbb "/> <category android:name=" Android.        Intent.category.DEFAULT "/> <category android:name=" CCC "/> </intent-filter> </activity> </application></manifest>
View Code

Calling code

        Button btn=(button) Findviewbyid (r.id.button1);        Btn.setonclicklistener (new  Onclicklistener () {                        @Override            publicvoid  OnClick (View v) {                Intent Intent=new  Intent ();                Intent.setaction ("aaaaaaaaaaa");                Intent.addcategory ("CCC");                StartActivity (intent);            }        });
View Code

Show the second form of code

        TextView v1=(TextView) Findviewbyid (r.id.textview1);        TextView v2=(TextView) Findviewbyid (R.ID.TEXTVIEW2);        V1.settext ("active:" +getintent (). Getaction ());        Set<String> sets=getintent (). GetCategories ();        V2.settext ("Category:" +sets+ "");
View Code

Example 2

View and display Contact phone

Android Learning-intent

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.