1. Native System Judgment method
http://blog.csdn.net/xidiankk/article/details/49533245
According to this analysis, the necessary conditions are:
1) The way to emit intent (the way to start packageinstalleractivity)
Must Forresult
2) Intent must set the unknown source to False
Feel the design is rather lame, third-party apps can be arbitrary.
It is estimated that Chrome is not installed in the default way to meet the above conditions, so as long as it is under chrome is unknown.
And AppStore is wanton for it, all for Ming, which fool AppStore will his own set as unclear?
Packages\apps\packageinstaller\src\com\android\packageinstaller\packageinstalleractivity.java
2. Android Customization
Goal: Download only from your own App store.
All browsers and other stores cannot be installed. The SD card is not limited at this stage.
Consider the following scenarios:
1) custom system Android Marketplace app that specifies intent special data when starting packageinstalleractivity.
2) packageinstalleractivity Mandatory check of special data when Isinstallrequestfromunknownsource.
(but this will affect the system itself, the installation of the app, the first time the system should be pre-installed, when the pre-installed if also go this path is bullshit.) So do you want to distinguish it from pre-installed? )
3) Packageinstalleractivity is set to not allow installation of unknown sources. Isinstallingunknownappsallowed
http://www.android100.org/html/201307/18/3656.html
Alternative options:
Take a look at this earlier entrance, if it can be blocked early. This is a straightforward URI to judge.
http://blog.csdn.net/dadoneo/article/details/8047931
public void InstallPackage (
Final Uri Packageuri, Final ipackageinstallobserver Observer, final int flags,
Final String Installerpackagename)
InstallPackage of the Packagemanagerservice class
http://blog.csdn.net/dadoneo/article/details/8047931
How Android determines if the APK is an unknown source