The 13th chapter, the Implicit Intent Small demo (Android)

Source: Internet
Author: User

Mainactivity.java

package com.example.demo16;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.view.view;import Android.view.View.OnClickListener ; Import Android.view.window;import Android.widget.button;import Android.widget.linearlayout;public class Mainactivity extends Activity implements Onclicklistener {@Overrideprotected void onCreate (Bundle savedinstancestate) { Remove the activity title requestwindowfeature (window.feature_no_title); super.oncreate (savedinstancestate);//annotation original layout// Setcontentview (R.layout.activity_main);//Instantiate layout linearlayout llayout = new LinearLayout (this);// Layout Direction llayout.setorientation (linearlayout.vertical);//Add to Window Setcontentview (llayout);//Instantiate button B = New button ( This), B.setonclicklistener (this);//Add the button to the layout Llayout.addview (b);} @Overridepublic void OnClick (View arg0) {//TODO auto-generated method Stubintent Intent = new Intent ("myaction"); intent.a Ddcategory ("MyCategory"); StartActivity (intent);}} 
Androidmanifest.xml

Add a second activity to the file.

<application android:allowbackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@strin G/app_name "Android:theme=" @style/apptheme "> <activity android:name=" com.example.demo16.Ma Inactivity "android:label=" @string/app_name "> <intent-filter> <action an Droid:name= "Android.intent.action.MAIN"/> <category android:name= "Android.intent.category.LAUNCHER" /> </intent-filter> </activity> <!--This is the second activity start-and &LT;ACTI Vity android:name= "com.example.demo16.SecondActivity" > <intent-filter> <action Android Oid:name= "Myaction"/> <category android:name= "mycategory"/> <!--this line means the default Categ            Ory, be sure to write, if there is no mycategory, this line also to write--<category android:name= "Android.intent.category.DEFAULT"/> </intent-filtEr> </activity> <!--This is the second activity end---</application> 

Run:


Click the button to jump to


Note: Because the secondactivity file and layout is relatively simple, the code is not posted here

The 13th chapter, the Implicit Intent Small demo (Android)

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.