One app opens another sub-app+ app installation does not appear on the phone desktop

Source: Internet
Author: User

Boss temporarily let me do a demo, to implement an app to open another app

Requirements: Click on the Open button, have installed the words opened, no installation display installation

Sub-program can no longer display icon on mobile phone page

Parent Program Core Code

                       public void OnClick (View arg0) {
				//TODO auto-generated method stub
				Intent Intent = new Intent ();
				COM.EXAMPLE.DEMO2: Child package name               com.example.demo2.MainActivity: subroutine open page
		        componentname cn = New ComponentName (" Com.example.demo2 "," com.example.demo2.MainActivity ");
		        Intent.setcomponent (CN);
		        Intent.setaction ("Android.intent.action.MAIN");
		        try {
		            Startactivityforresult (intent, RESULT_OK);
		        } catch (Exception e) {
		            Toast.maketext ( Mainactivity.this, "No sub-apps, please download Install", Toast.length_short). Show ();
		        }
			}

Subroutines only need to set a line of code under the manifest file

<application
        android:allowbackup= "true"
        android:icon= "@drawable/ic_launcher"
        android:label= "@ String/app_name "
        android:theme=" @style/apptheme ">
        <activity
            android:name=" Com.example.demo2.MainActivity "
            android:label=" @string/app_name ">
            <intent-filter>
                < Action android:name= "Android.intent.action.MAIN"/>
                <!--<category Android:name= " Android.intent.category.LAUNCHER "/>-->//comment out this line
            </intent-filter>
        </activity>
    </application>

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.