Android - How to Intercept the 'Install Application' Intent

Interception of Installed Applications on android device

    intentAPP.addAction(Intent.ACTION_PACKAGE_ADDED);
intentAPP.addAction(Intent.ACTION_PACKAGE_CHANGED);
intentAPP.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
intentAPP.addAction(Intent.ACTION_PACKAGE_INSTALL);
intentAPP.addAction(Intent.ACTION_PACKAGE_REMOVED);
intentAPP.addAction(Intent.ACTION_PACKAGE_REPLACED);
intentAPP.addAction(Intent.ACTION_PACKAGE_RESTARTED);

//for storing list in db

for (int i = 0; i < AppsP.size() && i < Apps.size(); i++) {

DB.insertStmt.bindString(1, URLDecoder.decode(AppsP.get(i)));
DB.insertStmt.bindString(2, URLDecoder.decode(Apps.get(i)));
DB.insertStmt.bindString(3, 1 + "");
DB.insertStmt.bindString(4, "false");
DB.insertStmt.executeInsert();

}

//adding package notification
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_PACKAGE_ADDED)) {
String added_package = intent.getData().toString();
Log.i("PackageReceiver", "Package Added = " + added_package);
Intent Intent_add = new Intent();
Intent_add.setClass(context, ServiceAppsAdd.class);
Intent_add.putExtra("Package_Name", added_package.substring(8));
Intent_add.putExtra("Status", status_new);
context.startService(Intent_add);

Web browser application - how to intercept URL intents?

Try adding both intent filters

        <intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:scheme="http"
android:host="*"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:scheme="https"
android:host="*" />
</intent-filter>

Install Application programmatically on Android

You can easily launch a market link or an install prompt:

Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///path/to/your.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);

source

Intent goToMarket = new Intent(Intent.ACTION_VIEW)
.setData(Uri.parse("market://details?id=com.package.name"));
startActivity(goToMarket);

source

However, you cannot install .apks without user's explicit permission; not unless the device and your program is rooted.

Way to know if my application is installed

If you want to execute any code from app A, it has to be already installed (it's obvious, isn't it?), so you can't check from your app A whether your app APP is installed or not.

It's like if you want to know when you are dead: after you die, it will be impossible to know it. On the other hand, someone else can know when you die... same for the Android scenario: an app B can know whether app A is installed or not (by using getInstalledPackages or intents or whatever).

hook between downloading and installing application from android market

See this question. You can determine that an app has been installed, but not intervene, within the Android security model (unrooted devices).

Perhaps Google is planning on enabling a more antimalware-friendly API in the future: however, anything that is permitted to do what traditional antivirus packages comes dangerously close to rootkit territory...



Related Topics



Leave a reply



Submit