Android Display intent to activate another activity

Source: Internet
Author: User

Android jumps to another interface, which is the app's usual operation. We can jump to the interface of the application itself, and also jump to the application interface of the system.

Effect:

To open the software:

Jump to the second interface:

Jump to the interface of the system application:

The accompanying code is as follows:

Main interface Code:

1  Packagecom.yy.twoactivity;2 3 Importandroid.app.Activity;4 Importandroid.content.Intent;5 ImportAndroid.os.Bundle;6 ImportAndroid.view.View;7 8  Public classMainactivityextendsActivity {9 Ten @Override One     protected voidonCreate (Bundle savedinstancestate) { A         Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main); -     } the      -     /** - * Click the event to jump to the second screen when the user clicks -      * @paramView +      */ -      Public voidClick (View view) { +         //Intentions AIntent intent=NewIntent (); at         //setting up packages and Interfaces -Intent.setclassname ( This, "Com.yy.twoactivity.SecondActivity"); -         //jump to the new set-up interface - startactivity (intent); -     } -      in     /** - * Click events to activate the system's application interface to      * @paramView +      */ -      Public voidClick2 (view view) { the         //Intentions *Intent intent=NewIntent (); $         //set up packages and interfaces for pre-open system appsPanax Notoginseng         //Cmp=com.android.gallery/com.android.camera.gallerypicker -Intent.setclassname ("Com.android.gallery", "Com.android.camera.GalleryPicker"); the         //jump to the new set-up interface + startactivity (intent); A     } the}

Create a second activity:

1  Packagecom.yy.twoactivity;2 3 Importandroid.app.Activity;4 ImportAndroid.os.Bundle;5 6  Public classSecondactivityextendsActivity {7 @Override8     protected voidonCreate (Bundle savedinstancestate) {9         Super. OnCreate (savedinstancestate);Ten Setcontentview (r.layout.activity2); One     } A}

Attention:
The activity information must be configured in the Androidmanifest.xml file

1<Application2Android:allowbackup= "true"3android:icon= "@drawable/ic_launcher"4Android:label= "@string/app_name"5Android:theme= "@style/apptheme" >6<Activity7Android:name= ". Mainactivity "8Android:label= "@string/app_name" >9<intent-filter>Ten<action android:name= "Android.intent.action.MAIN"/> One  A<category android:name= "Android.intent.category.LAUNCHER"/> -</intent-filter> -</activity> the<Activity -Android:name= ". Secondactivity " -Android:label= "@string/app_second_name" > -</activity> +</application>

Android explicitly activates another activity

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.