alarm is automatic running after reboot even alarm is not set android - android

Hi I am developing an application in Android which playing Alarm. It can reset alarm after reboot phone . But there is a problem that, it is running alarm even if alarm is not set at all. Please help me.

You should check you if your 'if' statement is correct before your instruction is running, or if you don't have register 'ON_BOOT_RECEIVER' broadcast in your manifest.
Anothor solution is to debug your code with System.out.println() to check each variable state, or each step.

Related

Create a ringtone that can not be turned off until the task is completed

I'm trying to make an android alarm app that only turns off when completing a task. I tried using an activity that was turned on for the user to do the task when it was time for the alarm. The problem is that when I use the taskmanager to kill the activity, my alarm clock goes off, I'm thinking of using overlay, but the permissions on the different devices sometimes do not work as expected (I tried running The android is good, but not on xiaomi. Can anybody give me ideas on how to handle this problem?

Android - Debug app on phone reboot

I need to reset alarms after the phone restarts.
I set up a BroadcastReceiver which starts a Service if the intent equals android.intent.action.BOOT_COMPLETED.
The question is: how can I debug this? I mean, I would like to use the Android Studio debugger to see if the Service started correctly. How can I do that?

Is there a faster way to call a receiver than on boot completed?

some context:
I have an alarm app I use for myself that locks the screen when the alarm goes off for the duration you request prior. Essentially your phone is a ringing brick for x minutes. The only problem is my sleepy self is very irrational and in the morning I figured out that if I turn off the phone and get to the app location and uninstall it before the receiver gets called (boot completed) then I can bypass it bricking my phone. This didn't use to be a big deal when my LG G2 was on 4.2.2 because of how fast the receiver was called I would usually have to restart my phone about 5-8 times to uninstall the app before it was bricked so I just gave up and quit trying. Now, I upgraded to 4.4.2 and the receiver is called about a full 10 seconds later letting me delete the app on the first try every time. Making the app completely useless.
What I have tried:
I have tried using quick_boot in the manifest but I believe that this is only for HTC because on_boot doesn't get called for that OS for some reason. I have also tried the user present which only seems to work after the boot is completed when doing things like unlocking your phone.
Is there really no way to make onReceive be called quicker than onBoot? It would make sense if there isn't , I'm just hoping someone could provide a definite answer either way.
In some cases it is. I'm not 100% sure but i think (some) systemapps have higher priority then the ACTION_BOOT_COMPLETED event. AND there is ACTION_SCREEN_ON which should be triggered before ACTION_BOOT_COMPLETED.
I should have answered this a week or so after I asked this question because I found a pretty useful workaround, although, it is a little sloppy.
I made a new activity(homeLock) with the intent filter . homeLock extends activity and my old main activity(alarmMain) extends homeLock now instead of activity. All homeLock does is start the overlay service(so you can't stop the alarm/use the phone) that will be turned off by alarmMain when it determines whether an alarm should be ringing currently or not. In alarmMain there is a button now that says "change home" which lets you make homeLock the home application. Now, when you turn off the phone and restart to try and delete the application before onBootReceived is called which starts the broadcast receiver(triggers alarm and overlay) the homeLock activity is called which puts an overlay on the screen until it can be removed after the application determines if an alarm should be playing or not (after onBootReceived).
Basically, before you go to sleep just set this application as your home application from within the app or through settings. Now, it should be impossible to delete the application or turn off the alarm once it has started ringing until it has rung its duration because there will always be an overlay on the screen even when restarting the phone.
Obviously this addition is only needed for phones that boot slowly or extremely degenerate sleepers, or both like me. While it is unlikely this will help anyone because it is such a unique problem I thought I should post the workaround I have been using just in case someone does end up finding it useful.

Save Alarm after Reboot in Android

I am new to android. I was going through the manual, and read following:
Registered alarms are retained while the device is asleep (and can optionally wake the device up if they go off during that time), but will be cleared if it is turned off and rebooted
Can the alarm be saved in the app. If yes Can you please tell me how.
Can you please provide me with the code.
This should get you going.
In short, you relieve your app from keeping a watch on the alarm itself.
Instead you tell the system to keep track of it for you, and just create a class that should be awoken by the system once the alarm goes off.
http://www.vogella.com/articles/AndroidServices/article.html#scheduleservice_scheduling

Android BroadcastReceiver not working after install

Greetings! I'm working on an application that has a BroadcastReceiver listening on "android.intent.action.PHONE_STATE", which is run when the phone state is changed (I used it to run code when an incoming call is detected). This works fine on most of my test phones, but a few don't seem to trigger the receiver at all. However, once these problem phones are restarted everything works as expected.
Is there a reason these phones need to be restarted before the BroadcaseReceiver can pick anything up? Is there a way I can detect if it isn't running and manually "start" the BroadcaseReceiver? I'm stumped, so I'd appreciate any help you can offer.
Thank You.
To expand on the issue: starting from Android 3.1, installed applications are put in "STOPPED" state. To invoke BroadcastReceiver(s) from stopped application an additional broadcast intent flag is required.
More details: http://developer.android.com/sdk/android-3.1.html#launchcontrols
I created FLAG_INCLUDE_STOPPED_PACKAGES constant (=32) in my application (for pre-Android 3.1) and just add it to my broadcast intent intent.addFlags(FLAG_INCLUDE_STOPPED_PACKAGES);
Is there a reason these phones need to be restarted before the BroadcaseReceiver can pick anything up?
Assuming that your application has its BroadcastReceiver registered in the manifest for the PHONE_STATE broadcast, it should work immediately upon install. If it does not, it feels like a buggy ROM to me.
Is there a way I can detect if it isn't running and manually "start" the BroadcaseReceiver?
No, mostly because it's not running, usually, even when things are working. An instance of your BroadcastReceiver is created at the point of the Intent - <intent-filter> match, it is called with onReceive(), and the BroadcastReceiver is disposed of once onReceive() returns.

Categories

Resources