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>
Related
This question already has answers here:
Receiving package install and uninstall events
(5 answers)
Closed 4 years ago.
We have Android app which detects if apps are installed/ uninstalled on device or not.
with the help of manifest file which is as below:
<action android:name="android.intent.action.PACKAGE_INSTALL"/>
<action android:name="android.intent.action.PACKAGE_ADDED"/>
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
The android app receives broadcast from internal systems and send it to our servers.
But after API 26 android OS is not giving broadcast for Package_Installed.
Dose anyone know how to detect the app installation after API lever 26.
Apps that target Android 8.0 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest. Apps will still receive broadcasts if they register their BroadcastReceiver with Context.registerReceiver() and that context is still valid.
https://developer.android.com/about/versions/oreo/background#broadcasts
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.
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"
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.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Android, how to determine if a reboot occurred?
I have an app that I would like to always be running on my phone.
Is it possible to have an Android app programmatically start after the phone has been power cycled?
Add permission android.permission.RECEIVE_BOOT_COMPLETED to your manifest. Write a broadcast receiver and add this filter to the manifest:
<receiver android:name=".MyBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
Have your receiver launch any service or perform any task it chooses.
I don't think it's a good idea to try to launch an activity at boot time, but maybe it would work out ok.
It's an OK idea to have an app start after a reboot. It's not OK to put an Activity into the foreground after a reboot. Activities should always be under user control. In general, try not to out-guess the users.
However, you may have an interesting use case, so please post it.