Code to implement the installer, which is to turn on the system installation action

Source: Internet
Author: User

1, the following directly to the demo, specific instructions to see code comments:

public class Mainactivity extends Activity {@Override protected void onCreate (Bundle savedinstancestate) {s        Uper.oncreate (savedinstancestate);                        Setcontentview (R.layout.activity_main);         public void installapk (View v) {String path=environment.getexternalstoragedirectory (). toString ();         File File=new file (path, "phone.apk");         Uri uri=uri.fromfile (file);//System.out.println (path);         Intent intent=new Intent ();         Intent.setaction (Intent.action_view),///Intent.setdata (URI),////settype Specifies the data type, it empties the intent bound data, and therefore will be abnormal,//  If you set the type earlier, and then set the data, the setting type is not valid, so call the following API, the following is a description of Settype://this is used to create intents this only specify a Type and not data,//for example to indicate the type of data to return Intent.settype ("APPLICATION/VND.         Android.package-archive "); If the data type is not set, eventually the application is installed, but the browser intent.setdataandtype (URI, "Application/vnd.andRoid.package-archive ");    StartActivity (Intent); }    }

2, the file of the APK data type is found in the Tomcat/conf/web.xml, about the MIME type data type, you can search in the Tomcat/conf/web.xml file to find the relevant data type, MIME type is now recognized, Data type standards, the browser also distinguishes between different media resources by MIME type.

Code to implement the installer, which is to turn on the system installation action

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.