I want to create such a service which start when any new application is installing on android device. so how to know any application getting installed in android device, is there any Intent event is fired ?
<receiver android:name="r1">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/> <data android:scheme="package"/>
</intent-filter>
</receiver>
you can try this broadcast receiver....
also go through
"android.intent.action.PACKAGE_REMOVED"
"android.intent.action.PACKAGE_REPLACED"
might come in handy...
Related
I am making an android app that will check for any vulnerability and malicious detection in android app being installed. now what i want is when user is installing any app then before the app get installed on device i get notified but broadcast receiver so that i can check the app for detection?
i have tried PACKAGE_ADDED but it is notifying me after the app has installed .plz tell me how can i do.i have used this code
<receiver
android:name="MyReceiver"
android:enabled="true"
android:priority="0" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" >
</action>
<action android:name="android.intent.action.PACKAGE_REMOVED" >
</action>
<data android:scheme="package" />
</intent-filter>
</receiver>
The logic in your description is to detect a package that not being installed. Why not to trigger some methods inside the uninstalled package and detect the related reaction, Or reverse the apk to the source code then analysis what you want.
To write an activity which may or may not be a launcher activity:
PackageManager pm = getPackageManager();
Intent appStartIntent = pm.getLaunchIntentForPackage("com.your.broadcast.receiver.package");
if (null!= appStartIntent)
{
startActivity(appStartIntent);
}
Also, you can try intent flag withFLAG_INCLUDE_STOPPED_PACKAGES to access the application that is stopped. Hope this could help you.
I am writing an app that has a potentially long running and intensive process that needs to run once per install of my app. Is there a way that I can have something run this process while the .apk is being installed, or immediately after?
You cannot run anything after JB until the user opens your app (for security reasons). You just need to ensure the user understands what is happening. Perhaps tell the user you will notify them when the app is ready or entertain them until the long running process is complete. You really have no other options.
Prior to that you could have a Broadcast receiver that listens for package updates with a negative priority and it would run after your app installed. Like this:
<receiver android:name=".InstallIntentReceiver" android:enabled="true">
<intent-filter android:priority="-999">
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_INSTALL" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
And in the receiver start a service that would do your long running process.
I am making an app and want to know when the app is uninstalling. For doing it, I used BroadcastReceiver but I don't know where is my code is wrong? (when my app is uninstalling, BroadcastReceiver can't receive any message about uninstalling)
It's my app's Manifest:
<receiver android:name="receiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_DATA_CLEARED"/>
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
<action android:name="android.intent.action.UID_REMOVED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<action android:name="android.intent.action.MEDIA_REMOVED"/>
<action android:name="android.intent.action.MEDIA_BAD_REMOVAL"/>
<action android:name="android.intent.action.BATTERY_OKAY"/>
<data android:scheme="com.example.testpermission"/>
</intent-filter>
You cannot get an event when your own app is uninstalling. See here. There is also a post on the subject here.
You can't, but if you have second installed application on the device - you can get notification via that application about the uninstallation of the first one (as far as I remember).
I believe that the application cannot monitor its own uninstall from two reasons:
It will make it much harder to uninstall application (some evil apps might even try to do something bad when their application is being removed).
If you remove application - you cannot run it, or send it events! The app should be closed for clean deletion.
About how to do it from second app:
Your second app should be a receiver to the ACTION_PACKAGE_REMOVED event (read about BroadcastReceiver, and see: http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED)
I am new to android. I am using a Broadcast receiver which listens when a app is installed or removed.. When a app is installed or removed my Broadcast Receivers's onReceive(context,intent) will be called.. Now i need to get the info about the application installed or removed (Mainly the package name)..
Plz help
You can try this receiver and permission. (But this seem only work in /system/app)^^"
<receiver
android:name="com.your.receiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package"/>
</intent-filter>
</receiver>
<uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />
All the information you want is in the Intent extras.
Look at How to find the package name which has been uninstalled when using Intent.ACTION_PACKAGE_REMOVED
I have a pro key application package for my application, and I would like to set up a BroadcastReceiver to receive intents when the pro key package is added or updated. Here's my code:
<receiver android:name=".Receiver">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<data android:scheme="package" android:path="com.test.key"/>
</intent-filter>
</receiver>
The code starts up the receiver on every app I install or update the com.test.key app, but it fires for every other apps as well. How can I listen for package updates for com.test.key only?
I know how to do it in the Receiver.java (intent.getData().getSchemeSpecificPart()). I'm looking for a way to do the filtering in the Android Manifest, so the broadcast doesn't get fired every time user installs an app.