Call back on new App install [duplicate] - android

This question already has answers here:
Receiving package install and uninstall events
(5 answers)
Closed 5 years ago.
I want to perform some action in my app when a new other application is installed in the device.
Is there any way I can do that? TIA

You should register for a broadcast when a package is added/removed, where android system broadcast a message to the all the registered apps.
so in your manifest add a broadcast receiver.
<receiver android:name=".AppListener">
<intent-filter android:priority="{highInteger}">
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
<data android:scheme="package"/>
</intent-filter>
</receiver>
Where AppListener is your java class where in onReceive() you can perform the desired operation.
Comment for any further doubts.

Related

How to protect FCM service with permission or something [duplicate]

This question already has answers here:
How to address android lint complaint about exported Firebase Messaging service implementations?
(2 answers)
Closed 10 months ago.
I developed an android app with fcm implementation. After completion I done the app vulnerability testing and got the below result.
(com.app.MyFirebaseMessagingService) is not Protected. An
intent-filter exists.
high
A Service is found to be shared with other apps on the device
therefore leaving it accessible to any other application on the
device. The presence of intent-filter indicates that the Service is
explicitly exported.
Same result I got for the service MyFirebaseInstanceIDService. Below is my Manifest file code.
<service android:name="com.app.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="com.app.MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
Usually we will add a custom permission to protect a service from get accessed by other application. But how to do that for FCM service? or any other solution for this problem? Please help.
you don't have to worry about firebase take care of the security side link
FirebaseInstanceIdService performs security checks at runtime,
no need for explicit permissions despite exported="true"

How to get notify before uninstalling app in android [duplicate]

This question already has answers here:
Is it possible to detect Android app uninstall?
(8 answers)
Closed 6 years ago.
I am working in app that needs to call an api, Webservice before uninstall app so please let me know if any solution to call before uninstall or any process that called before uninstall app.
You could try adding a BroadcastReceiver listening for android.intent.action.PACKAGE_REMOVED events.
You Register your BroadCastReceiver with this filter:
<receiver android:name=".MyBroadCastReceiver">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>

How to detect android phone is being turned off? [duplicate]

This question already has answers here:
handling phone shutdown event in android
(3 answers)
Closed 9 years ago.
I want to do something at instant the user turns off android phone. How can my app detect it programatically?
http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN`
<receiver android:name=".ShutdownReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
<action android:name="android.intent.action.QUICKBOOT_POWEROFF" />
</intent-filter>
</receiver>
This is what can provide you an insight of the OS you are working on, and not about developing an app that would run on any device, as you have not made OS's for them.
Just pull a branch of android, customize it according to your wish and in your manifest remove the filters, permissions that don't allow you to do that, or add your own. Now, you have to play with the battery if I talk of more depth.
But if you just want to trigger the click on power off then it's far simpler then.
Add in your manifest:
<receiver android:name=".ShutdownReceiver">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
<action android:name="android.intent.action.QUICKBOOT_POWEROFF" />
</intent-filter> </receiver>
Now a broadcast receiver for Action SHUT DOWN will work for you.
http://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN
Implement a BroadcastReceiver for ACTION_SHUTDOWN.

I am making an app and want to know when the app is uninstalling

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)

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

Categories

Resources