Restrict an APK to work for certain days - android

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.

Related

Sending a push notification directly from the app

Not too experienced with mobile development, but I wanted to know if this was possible.
After the user installs the app (android or ios), the app should at least once a day "wake-up" and show a push notification to the user.
Is this possible?
If I understood you correctly, I believe that you need setup a recurring alarm using AlarmManager. You also need to setup starting alarm service on device reboot. You can write a method that does what you want so it get executed when the alarm runs e.g. show notification. The following links should help you:
Repeat Alarm Example In Android Using AlarmManager

I want to generate android notification or alarm every day

In my application i need to deploy a some kind of reminder. that every day at any fixed time my application generate a notification..
and it happens if my application is running or not. (e.g by using background service)
I am able to generate notification, but im un able to create logic to generate it every day. Please help if any one understand what i want. Thanks in advance.
See below link and this is work for me.
Create alarm set on a specified time, using AlarmManager
Repeat alarm everyday accurately

Broadcast receiver not working when app is cleared from RAM

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

Does uninstalling an Android Application kill any alarms configured?

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.

Android Notification trigger when the application is in the background

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.

Categories

Resources