Android launch code for third-party programs

Source: Internet
Author: User

Method One:Intent Intent = new Intent ();
  • intent.setclassname (<package< Span style= "color:black;" > name>, <class  name>);   
  • StartActivity (Intent);

Method Two:
  1. Intent i=new Intent;
  2. ComponentName com= New componentname (<package name>, <calss name>);
  3. I.setcomponent (COM);
  4. StartActivity (i);

Start the Media Library

Intent i = new Intent ();

ComponentName comp = new ComponentName ("Com.android.camera", "Com.android.camera.GalleryPicker");

I.setcomponent (comp);

I.setaction ("Android.intent.action.VIEW");

StartActivity (i);

Start the camera

Intent mintent = new Intent ();

ComponentName comp = new ComponentName ("Com.android.camera", "Com.android.camera.Camera");

Mintent.setcomponent (comp);

Mintent.setaction ("Android.intent.action.VIEW");

StartActivity (mintent);

Start Htmlviewer and open the specified file note that TXT cannot be ANSI, otherwise it will be garbled

Intent Intent = new Intent ();

ComponentName cn = New ComponentName ("Com.android.htmlviewer", "com.android.htmlviewer.HTMLViewerActivity");

Intent.setcomponent (CN);

Uri uri = uri.fromfile (New File ("/sdcard/demo.txt"));

Intent.setdataandtype (URI, "Text/plain");

StartActivity (Intent);

Android launch code for third-party programs

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.