0

How can I identify an app is uninstalled, Based on that I want to change the status from 1 to 0 in my Database for generating

OTP

. If the status not changed OTP won't generated. Any Solution? Thanks

toKrause
  • 512
  • 1
  • 4
  • 13
maheshd
  • 13
  • 6
  • 2
    Possible duplicate of [Is it possible to detect Android application uninstall?](http://stackoverflow.com/questions/27141707/is-it-possible-to-detect-android-application-uninstall) – Eduardo Mar 08 '16 at 09:58
  • Thanks, But OTP generation in our app is based on status variable. After installing our App status changed 0 to 1. My intention is when app is uninstalled again status variable changed from 1 to 0 – maheshd Mar 08 '16 at 10:06
  • You cant make any server call to inform your server about the app getting uninstalled. What can be your best bet is to write a file (better a hidden one) in external storage of the device when the app is installed. So the logic would be every time your app is installed it will check for that file if found that means your app was installed before and if not found consider it as fresh install and write a file. Be-aware user can see and delete the files in external storage so you can try using hidden one cant guarantee its existance. – Sandeep Bhandari Mar 08 '16 at 10:12
  • You could try to use GCM for it. You won't recognize the moment the user uninstalls your app but I believe that you can tell by the error message of GCM when trying to send a message to the user whether the app has been uninstalled. So you would need a script which is trying to send a message using GCM to the users and changing the status from 1 to 0 if the message could not be delivered. I am not sure whether this is the only case that a message could not be delivered, it is just an idea. ;) :) – Jason Saruulo Mar 08 '16 at 10:28
  • Other solution "could be", make your app send something to your database every day, say midnight. If no data is received for multiple days, assume, it has been uninstalled. Be aware, it could also be due to no internet connection but you don't have to generate OTP in this case. It is just an idea, I am not sure about your logic. – AL̲̳I Mar 08 '16 at 10:33
  • @maheshd I removed the unrelated tag to otp (the open source distribution of Erlang). Please read the tag descriptions, when adding tags to your question. – toKrause Mar 08 '16 at 15:10

2 Answers2

0

No. You cannot check that your application is going to uninstall.

When the user uninstalls the app, at first the process is killed, then your apk file and data directory are deleted, along with the records in Package Manager that tell other apps which intent filters you've registered for.

Malwinder Singh
  • 6,644
  • 14
  • 65
  • 103
0

Thanks for All Suggestions,

I want this scenario for OTP request. Before sending OTP to Mobile we should check whether the Mobile number existed or not. If it exists then delete the records which already had with this number on Database instead of changing status '1' to '0'. It Works for me.

maheshd
  • 13
  • 6