Does a android App work if phone is switch off [closed]

杀马特。学长 韩版系。学妹 提交于 2019-12-06 02:12:03

问题


Whether it is possible to launch an android application like alarm while the phone is switched off.


回答1:


Technically Android is based on a modified Linux kernel and all processes running in Android are regular Linux processes. As such, when the kernel goes down then all processes also shutdown.

Alarm Manager is a system service which is running, along with other system services, inside a single Linux process (System Server) through its Dalvik VM instance. As I've already said, System Server is also a Linux process like other processes and will shutdown once whole kernel has stopped running.

Basically, all Android system services (e.g. Notification manager, Package manager, Camera, ...) are running inside that System Server standalone process. (However, in newer versions of Android some of them are slitted up to multiple processes). And this process is no longer running whenever the kernel stops.




回答2:


A bug had been filed almost 5 years ago regarding Android device's alarms not triggering when device is turned off.. It's status was then changed to "enhancement request"

And as you go deep down in that thread, you can see that it was "declined" . So officially Android doesn't support it, however some vendors have implemented this feature in their vendor specific ROM.




回答3:


@Anand Jain : Sorry .Android Does not Support This .

Working Process Of Alarm Manager

When an alarm goes off, the Intent that had been registered for it is broadcast by the system, automatically starting the target application if it is not already running.

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.

Courtesy

AlarmManager has access to the system alarm .services.getSystemService(Context.ALARM_SERVICE). This intent starts the target application if it is not running. It is recommended to use AlarmManager when you want your application code to be run at a specific time, even if your application is not currently running.

AlarmManager when the phone is turned off - ANDROID

https://code.google.com/p/android/issues/detail?id=1942




回答4:


No, if the phone is off, it can't do anything.




回答5:


NO, it is not possible to launch any android application when phone is switched off!!




回答6:


Alarm does not work when device is off by default in Android as it should be supported from lower layers of platform stack which are vendor specific.

Some vendor chose to implement this feature and some does not.

refer this link for more details.

Coming back to question, yes it is possible to wake device from power off provided you have access to lower layers (firmware) of platform stack and underlying hardware supports it, in short if you are working for a device vendor.

For normal 3rd party application developers it is not possible right now. It can be possible in future if android along with vendors deside to provide support for this feature.




回答7:


No, It's not possible to run your code when device is turned off.

But yes., you can achieve functionality like Alarm(Since your are asking "how alarm is work?? ").

Step - 1 : You can use AlarmManager class for setting alarm.

Step - 2 : Store the value of time to trig alarm in SharedPreferences

Step - 3(Optional) : You may want to store some data with events of ACTION_SHUTDOWN or QUICKBOOT_POWEROFF when android device turn off, link1.

Step - 4 : You also get device boot event in andoid with the help of RECEIVE_BOOT_COMPLETED(link2), and at a time you can reset your AlarmManager with the difference of device current time and time you've stored in SharedPreferences.




回答8:


No, If the phone is off, it can't do anything. If it's in sleep mode where the screen is off and it's not in use then the alarm will still function as will other types of notifications. I have never tried this specifically on a Galaxy S but I am fairly confident this is a universal rule.



来源:https://stackoverflow.com/questions/32644120/does-a-android-app-work-if-phone-is-switch-off

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!