How to call the system package to install your own apk?

Source: Internet
Author: User

In fact, it seems that I don't know how to implement it. In fact, the system's intent is called to complete the installation.

Case-driven:
123456789101112131415161718192021222324 public void onSuccess(File t) {     // Replace the application when the download is successful     // TODO is not very understandable.     // Download and install the application.     // <action     // android:name="android.intent.action.VIEW"     // />     // <category     // android:name="android.intent.category.DEFAULT"     // />     // <data android:scheme="content" />     // <data android:scheme="file" />     // <data     // android:mimeType="application/vnd.android.package-archive"     // />     Intent intent = new Intent();     intent.setAction("android.intent.action.VIEW");     intent.addCategory("android.intent.category.DEFAULT");     intent.setDataAndType(Uri.fromFile(t),            "application/vnd.android.package-archive");     Log.i(TAG, "Download successful");     startActivity(intent);     super.onSuccess(t); }

This code is implemented in the breakpoint download function, that is, when the application is successfully downloaded, to install the update file, you need to know how to call the Intent, that is, how to setAction, addCategory, and setDataAndType. These items can be obtained from the source code. So here is a key question. How can we find the required intent settings through the source code?

Find the apps in the source code and find a packageInstaller. The name indicates that this is a system application that installs the application. How can I call it? You can view the following information in the configuration file:

Case-driven:
1234567891011 <activity android:name=".PackageInstallerActivity"                 android:configChanges="orientation|keyboardHidden"                 android:theme="@style/TallTitleBarTheme">             <intent-filter>                 <action android:name="android.intent.action.VIEW" />                 <category android:name="android.intent.category.DEFAULT" />                 <data android:scheme="content" />                 <data android:scheme="file" />                 <data android:mimeType="application/vnd.android.package-archive" />             </intent-filter>         </activity>

Then you can know the specific call method, and set the corresponding parameters to install your own application.

You are welcome to leave a message. This is one of my previous notes. Now I want to record some of my previous notes on the Internet. Of course, there will certainly be some leaks.

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.