How to make broadcast receiver to listen event for particular app in android? -
i developing app contain list of app, when user click of particular app list shown him directed website can download app listen app download add broadcast receiver in android menifest.xml.the problem broadcast receiver listen if app downloaded in system app also.what want broadcast receiver should listen events app when app open closed.
here java code:-
public class receiver extends broadcastreceiver { @override public void onreceive(context context, intent intent) { // check if application install or uninstall , display message accordingly if (intent.getaction().equals("android.intent.action.package_added")) { // application install log.e("package added:-", intent.getdata().tostring()); } else if (intent.getaction().equals("android.intent.action.package_removed")) { log.e("package removed:-", intent.getdata().tostring()); } else if (intent.getaction().equals("android.intent.action.package_replaced")) { log.e("package replaced:-", intent.getdata().tostring()); } }
}
here xml code:-
<receiver android:name=".receiver"> <intent-filter android:priority="100"> <action android:name="android.intent.action.package_install"/> <action android:name="android.intent.action.package_added"/> <action android:name="android.intent.action.package_removed"/> <data android:scheme="package"/> </intent-filter> </receiver>
kinldy me trying week plsss.
there no way know whether package installed app information in intent
received broadcastreceiver
. technically, app isn't installing anything, system (third party apps not have privilege install other apps).
you have check package name intent
data , compare apps user downloaded app. that's best can do.
Comments
Post a Comment