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.