Android Note: Intent

Source: Internet
Author: User

One, the explicit intent is as follows:
(1) The intent constructor passed in two activity file names
Intent Intent = new Intent (firstactivity.this, Secondactivity.class);
StartActivity (Intent);
(2) Remember to register for Secondactivity in Androidmanifest.xml
<activity android:name= "Secondactivity" >
</activity>

Second, the implicit intent is as follows:
(1) A string that directly passes the action
Intent Intent = new Intent ("Com.example.intentdemo.ACTION_START");
StartActivity (Intent);
(2) Remember to register in Androidmanifest.xml.
Only one action can be specified in each Intent, but it is possible to specify multiple category.
<activity android:name= ". Secondactivity ">
<intent-filter>
<action android:name= "Com.example.intentdemo.ACTION_START"/>
<category android:name= "Android.intent.category.DEFAULT"/>
</intent-filter>
</activity>

Three. Open a Web page
Intent Intent = new Intent (Intent.action_view);
Intent.setdata (Uri.parse ("http://www.baidu.com"));
StartActivity (Intent);

Four. Call the system dial-up interface
Intent Intent = new Intent (intent.action_dial);
Intent.setdata (Uri.parse ("tel:10086"));
StartActivity (Intent);

Five. Passing data to the next activity
Intent intent=new Intent (firstactivity.this,secondactivity.class);
Intent.putextra ("Extra_data", "hello,secondactivity");
StartActivity (Intent);

Android Note: 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.