Is there any way to determine programmatically the time at which an Android application was installed? I don't see anything in PackageInfo, etc.
--EDIT--
To clarify, App A is installed at Time X. At some later time, Time Y, App B is installed. Is there any way App B can know when App A was installed? The link How to get app install time from android indicates that reading the modify time on the source dir of the App is sufficient. Is this really correct? Why?
When you install/update a non-protected app, it's apk file gets written to /data/app/package.name.apk, confusingly referenced as sourceDir (from my answer) resetting the timestamp to the current one. That's it.
are you trying to find the time when YOUR app was installed, or other apps? If you are only interested in your own app, you can add functionality to your app that checks if this is the first time the app has been run. if it is, get the system time and save it in a file/database. then whenever you want it, you can open the file/query the database for it.
Was this helpful?
Register a BroadcastReceiver for the corresponding Intent.
Related
I want to create an apk, without an user interface in android. And I need to start a Service as soon as the Applicaton gets installed on the Device. Is there any possible way to create an apk without UI.
Thanks in advance.
And I need to start a Service as soon as the Applicaton gets installed on the Device.
Fortunately, that is not possible for an app installed through normal channels (e.g., the Play Store), for security reasons, since Android 3.1. Nothing of your app will run until something on the device uses an explicit Intent to start up one of your components, and that most certainly does not occur when your app is installed.
You are welcome to build your hardware, or your own custom ROM, that has your app pre-installed. In that case, you can arrange to be able to run right away.
yes, you have juste to create a Service or a BrodcastReceiver which do something you want
Is there any way to detect when an application begins installing? More specifically, when the system is running the packageinstall.apk - Can I capture this moment?
I want to alarm user before apk is installed. I have tried the ACTION_INSTALL_PACKAGE but it does not work. (ACTION_PACKAGE_ADDED is not what I want either.)
There is no easy way to do this. The best you could do is check after the app has been installed whether or not you want it on there and act accordingly.
How can I get open and close time for all installed app. I have to create a app that will calculate app usages statics on phone.
Thanks,
Ajay
On the application level you would need to run a service that periodically checks and tracks statistics itself. At the platform level, you should be able to easily make modifications to track this fairly accurately..
I donot think it is at all possible.
i am aware of android BROADCAST_PACKAGE_REMOVED for notify when any application is uninstalling from device.
Now it is possible that when i uninstall one application and that application do some work before and uninstall.
e.g: my application work with android contact if application uninstall at that time i want to change in contact data.
can i get any event for uninstalling app?
Thanks.
No.
(at least until the current version of Android)
In case it's any help, widgets do get notified when their last instance is removed. However, the app than contains the widget remains installed.
Is there a way to get a system notification when an app has been uninstalled?
I would like to maintain a table of all clients' info currently using my app. However, that seems impossible if there is no way to detect this event.
The first solution I can think of is to have an always running service in the background listening for android.intent.action.PACKAGE_REMOVED. But then would that service be killed once the uninstallation process has ended, or would it be stopped just before the process has kicked off? Also even if this is a solution it's has the potential to put off a lot of people when they realise that part of the app is running in the background.
Any suggestions? Thanks!
You could simply do it the other way round and maintain a table of users actively using your app. Just call a webservice at a point in the program that show it is active. If an app isn't used for a certain time mark it as inactive.
The documentation for the PACKAGE_REMOVED action says the following:
The package that is being uninstalled does not receive this Intent.
So you can monitor for other applications being uninstalled but not your own.
So you'll probably need track who is still using your application, not who has stopped using it. If you don't want the overhead of having your own server to do this you could use a free service like Flurry.
From Android document, the app uninstalled by user can't not get
Intent.ACTION_PACKAGE_REMOVE
But we can use other method to implement this feature. We all know that there is a directory named with your package name under the /data/data directory after your app installed by user. If your app is uninstalled by user, the root directory of your app(/data/data/com.example.yourappname) will be removed by system. The remove action happen immediately when user click "uninstall", and the directory will be removed by framework package manager system.
So, we can monitor the existence of your app data directory(which usually /data/data/com.example.yourappname) to detect if your app uninstalled by user.
In order to monitor this directory, we have to fork a detached process from JNI.
In this new fork process, we can use Linux system api inotify(7) or access(3) to determine the existence of app's data directory.
Here is a workable implementation. But it got the permission problem when try to send an intent to start system browser on high version Android device. I have no idea how to bypass this. However the example above is enough for your question.
Hope it will be helpful!
Android doesn't provide an inbuilt function for tracking the app uninstall.
Notification can be used as an alternate way to track the app uninstall. For this send notification on the app and track the status of the notification. Count the number of undelivered notification for a particular time period. If status of undelivered notification doesn't change in that particular time period, then consider that the app has been uninstalled from the device.
For example, i have used a cron script which run every 3 days and check the status of last 10 notifications delivered to the device (2 notifications are sent in a day). If all of these 10 notifications have status "undelivered", then the app is considered to be uninstalled from the device.