Android: How to get the installed App information using Broadcast receiver - android

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

Related

Broadcast receiver invoking on every reboot

I have registered a broadcast Receiver with which should wake the application up on every reboot,
receiver android:name=".Receiver.NewLocationReceiver"
<intent-filter>
<category android:name="android.intent.category.HOME" />
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="YouWillNeverKillMe" >
</action>
</intent-filter>
</receiver>
Still the BOOT_COMPLETE filter if failing to do its job, Unable to tackle a particular scenario. Is there anything I need to add so that I can completely avoid this situation.
Popular pitfalls:
BOOT_COMPLETED is delivered to all relevant (registered) broadcast receivers only upon unlocking the device.
It is delivered in some order, so you may be last in that list and will take some time.
Make sure you have the presmission <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

Will android install referrer receiver also listen to broadcasts of other apps installed with a referrer?

I have a Install referrer receiver in my manifest.
<receiver
android:name="xx.yy.zz.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
And I get the referrer in the broadcast receiver as:
String referrer = intent.getStringExtra("referrer");
My doubt is would the receiver also listen to broadcasts of other apps which are installed with a referrer.
I want to listen to broadcasts for my app only.
If this problem exists, what would be the solution for it?
<receiver
android:name="xx.yy.zz.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
**<data android:scheme="package" />**
</intent-filter>
</receiver>
add your package in the receiver and while receive the broadcast in the OnReceive method check for your package
this will solve your problem

How to know Application Installation is completed in android?

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...

Listening for package change events of certain package

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.

Android - How to start an application on the /sdcard after boot

Is there a way how to start and android application after a boot automatically if it is on the /sdcard?
Ok, probably by BroadcastReceiver. But which action is the right one?
ACTION_BOOT_COMPLETED - does not work if it is on the /sdcard (documented)
ACTION_MEDIA_MOUNTED - does not work if it is on the /sdcard (which is undocumented)
ACTION_EXTERNAL_APPLICATIONS_AVAILABLE - does not work, I do not know why
ACTION_USER_PRESENT - does not work if the BroadcastReceiver is registered in AndroidManifest (which is undocumented, but documentation bug has been reported)
Thanks
Jan
try using <receiver android:name=".BootCompleteReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
and this <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
perhaps QUICKBOOT_POWERON help u
Please mention it in manifest file.
</uses-permission>
<receiver android:name=".BootReceiver"
android:enabled="true"
android:exported="true"
android:label="BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
</receiver>
provide permission "android.permission.RECEIVE_BOOT_COMPLETED" as child of menifest.
and one more thing your app must not be installed in sdcard.
According to Google, you should not put any app you want to run at boot on an external drive.
"The system delivers the ACTION_BOOT_COMPLETED broadcast before the external storage is mounted to the device. If your application is installed on the external storage, it can never receive this broadcast."
http://developer.android.com/guide/topics/data/install-location.html#ShouldNot
I usually register every intent filter for a broadcast receiver both ways (Android Manifest as well as dynamically in a class that extends Application)
In AndroidManifest.xml as:
<receiver
android:name=".broadcastReciever"
android:enabled="true"
android:exported="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE" />
</intent-filter>
</receiver>
and in a class that extends Application:
registerReceiver(new broadcastReciever(), new IntentFilter(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE));
and don't forget to add RECEIVE_BOOT_COMPLETED permission and register the class which extends Application in the Android Manifest.
This should do; feel free to ask for any more help/clarification.

Categories

Resources