I want to create an android app which will tell me when I have unlocked my phone in past day also track the location where I have unlocked the phone using GPS. Is there a way to achieve this?
You have to use broadcast receiver for receiving system messages. For checking when the device is unlocked you can use ACTION_USER_PRESENT intent filter for you receiver. Start a service when your receiver receives broadcast from system and log your current location data.
This might help in the way - A way to get unlock event in android?
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
I'm trying to create a service that run in background in android.. That service should work only when the device is on sleep (Means that screen is off)..
I think that can be done using a service but I don't know how to detect if the phone is awake or not.. Any Idea ? Thanks..
For screen on-off state, you can try with ACTION_SCREEN_ON and ACTION_SCREEN_OFF intents, as shown in this blog post:
http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
From here : How to detect whether screen is on or off if API level is 4?
My application runs in the background and gets a notification when the volume on the device changes. The service then has to show a warning message based on the volume levels.
What kind of a service should this be.
Thank you.
For achieving this, you need to register a broadcastreceiver. Take a look at this question:
Android BroadCastReceiver for volume key up and down
I want to design an app that will make the LED blink whenever a message or a phone call is received. I've read about broadcast receivers but I'm not sure how to work with them or where to start.
If anyone can put me in the direction where I can perform an action whenever phone rings? Maybe a small example or tutorial link would be nice.
Regards
Saeed
This should help with the broadcast receiver stuff: http://www.vogella.com/articles/AndroidBroadcastReceiver/article.html
This should help with LED stuff (half way down):
http://mobile.tutsplus.com/tutorials/android/android-vibrator/