I am creating an Alarm in application to run at 8 Am every morning and process some business logic. Can somebody please confirm if the alarm would be killed/removed automatically when the application is uninstalled ? Or do I need to specifically handle PACKAGE_REMOVED intent to remove the alarm ?
Thanks a lot in advance.
Vinay
If you are using AlarmManager yes it does. As does force closing the app.
Related
I am new to android. I am making an alarm clock. Its working perfectly until the user clears the app from the RAM. On searching, I found that broadcast receivers don't work if the app is cleared from the RAM. So, what exactly should I do? Will sending the broadcast from a service help? Also if you have a link to a good tutorial to Services in android, pls do share. Also let me know if there is some other way to solve my problem.
In Xiaomi devices, you just have to add your app to Autostart list, to do so, follow these simple steps given below:
Open Security app on your phone.
Tap on Permissions, it'll show you two options: Autostart and
Permissions
Tap on Autostart, it'll show you list of apps with on or off toggle
buttons.
Turn on toggle of your app, you're done!
You can register broadcast receivers either inside the activity at runtime or in the manifest. You want to adopt the latter approach
In the past I have similar problems with AlarmManager, AlarmReceivers and this kind of things. There are some tips that can help you in your code:
Make sure that you are scheduling your alarm correctly.
Make sure that you are setting the propers permissions on the manifest.
Take care if the device is locked or it was rebooted.
There is a quite useful tutorial that helps me to control and make a "Hello World!" example with AlarmManager: AlarmManager Repeating Example
Note: In API 19 and higher, the method setRepeating is not exactly (maybe the alarm triggers at 10:00 or at 10:15), so you must use setExact.
Hope it helps!
You can register broadcast receiver in two ways
1. From your activity.
2. From your manifest.
if you registered broadcast throught activity, It wont receive after your activity is destroyed, So thats is where we register BroadcastReceiver in manifest.
This link will help you BroadcastReceiver
In android device if any user set alarm in default app then how can I detect or receive that alarm when its execute in my application. I don't know its possible or not if anybody knows please suggest me how can I do that.
Im creating an alarm-based app right now, this is what i found earlier :
Android get list of active alarms
Get all alarms saved in the alarm application
Its a bad news.
I need to make an APK in android, that should work for only one week if we install that apk in any android devices. Please suggest me how to do this. Thanks in advance
Regards
Anand
call a remote REST service that returns a no-go result after 1 week.
use the inbuilt android calendar and check for time.
You can't uninstall the application but what you can do is add a broadcast reciever and which will be called from an alarm and inside that broadcast reciever you can block the functioning of the application
http://www.techrepublic.com/blog/app-builder/use-androids-alarmmanager-to-schedule-an-event/2651
this link is helpful to set alarm set the alarm to 1 week from now which is
7*24*60*60*1000 milliseconds and it will trigger a broadcast reciever after 1 week you can block the functioning of the code then.
I would like my app to wake up after it has been updated using the market (play store).
How can I accomplish that?
By waking up, I mean the Application.onCreate() to be executed.
As Commonsware mentions, the ACTION_PACKAGE_REPLACED does the trick. You just need to compare your package name with the data for the intent, otherwise you catch all packages being replaced.
In newer API's (12 on up) there is the ACTION_MY_PACKAGE_REPLACED which is only sent to the application that was replaced.
In principle, having a manifest-registered receiver for ACTION_PACKAGE_REPLACED should have this effect. Android should have to terminate your process to do the update, causing a fresh process to be created to deliver this broadcast to you.
That being said, I haven't tried this.
All, in my new android application i need a notification to trigger if the app is not used for last four days. That is from the last use of application if 4 days gone and not using the application a notification need to come.
plz any help will be apreciated...
thanks in advance.....
You will have to manage it by yourself.
1.) Set a preference to the time you want the alarm to go off, it will save, even after reboot.
2.) you need RECEIVE_BOOT_COMPLETED permission and register a BroadcastReceiver in your manifest for the BOOT_COMPLETED
3.) just reset the alarm time to the time you need, from the preference.
I think that's very bad practise... but if you want to do it nevertheless, simply use AlarmManager.