wakelock

Keep a Service running even when phone is asleep?

假装没事ソ 提交于 2019-12-17 03:50:33
问题 I have a Service in my application which is designed to run every 10 minutes. It basically checks up on our servers to see if everything is running properly and notifies the user of any problems. I created this application for internal use at our company. My co-worker used the application over the long weekend and noticed that no checks were performed when the device went to sleep. I was under the impression that the Service was supposed to keep running in the background until I explicitly

Do I need to Use an AlarmManager and WakeLock to periodically use a LocationClient?

北慕城南 提交于 2019-12-14 02:31:03
问题 Posts from over a year ago suggest that it is necessary to use a WakeLock to reserve CPU to gather location information (CommonsWare in particular here Android Periodic GPS location updates with AlarmManager inside a Service). However I do not understand why I cannot simply call a Service every 28 minutes, connect the LocationClient, set a timer to wait 2 minutes, then get the most recent location, disconnect the client, and then stop the service. Because Commonsware and the user who forked

How to prevent app from closing when android device goes to sleep

点点圈 提交于 2019-12-13 07:49:52
问题 How do i prevent my app from closing when the device goes to sleep mode, i obsevered that anytime my device goes to sleep mode my app closes but i want it still open when my devices comes out of sleep mode. 回答1: Probably it is because you call the finish() method in the onPause(). 来源: https://stackoverflow.com/questions/28811831/how-to-prevent-app-from-closing-when-android-device-goes-to-sleep

Android app high CPU usage, no services or wakelocks

為{幸葍}努か 提交于 2019-12-13 05:48:19
问题 I've forked the system messaging app and it is consuming the majority of my CPU, and others have reported the same. I cannot for the life of me determine why. I figured the drainage could be possibly two things (because of how much it is draining): a wakelock that has not been released, or a service doing continuous computation. Here's what I have tried: adb shell dumpsys power This shows Wake Locks: size=0 so I am assuming it is not a wakelock issue (the app uses wakelocks, of course, but I

How can I keep my screen on using a background running app?

杀马特。学长 韩版系。学妹 提交于 2019-12-13 03:57:45
问题 I need to make an app that keeps the screen on even when the app is running in the background. I've tried: getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); But it only works when the app is running and can't run as a service. I've also tried wakelocks but SCREEN_BRIGHT_WAKE_LOCK and FULL_WAKE_LOCK have both been deprecated. The only wakelock left is PARTIAL_WAKE_LOCK. Is there someway to keep the screen on using the PARTIAL_WAKE_LOCK, ACQUIRE_CAUSES_WAKEUP, and some loops

How to prevent app from closing when android device goes to sleep

爷,独闯天下 提交于 2019-12-12 07:06:40
问题 How do i prevent my app from closing when the device goes to sleep mode, i obsevered that anytime my device goes to sleep mode my app closes but i want it still open when my devices comes out of sleep mode. 回答1: Probably it is because you call the finish() method in the onPause(). 来源: https://stackoverflow.com/questions/28811831/how-to-prevent-app-from-closing-when-android-device-goes-to-sleep

Android - Alarm with Wakelock not launching Service from intent

放肆的年华 提交于 2019-12-12 01:14:39
问题 I am writing an app and am having a bit of trouble with getting my Alarm BroadcastReceiver from starting a desired intent. The code is as follows: public void onReceive(Context context, Intent intent) { Log.d("Alarm:","Running WakeLock"); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, ""); wl.acquire(); WakeMe.wakelock = wl; Log.d("Alarm:","Running Intent (Service)"); Intent i = new

Using a wake lock

时光怂恿深爱的人放手 提交于 2019-12-11 19:32:32
问题 I have a sleep machine app that I want to still play the sound if the phone goes into stand by. I just edited to have the wake lock added and it is added in the manifest as well. It isnt working correctly but I am not sure why. package com.androidsleepmachine.gamble; import android.app.Activity; import android.content.Context; import android.media.MediaPlayer; import android.os.Bundle; import android.os.Handler; import android.os.PowerManager; import android.view.KeyEvent; import android.view

Inquiry related to AlarmManager and WakeLocks

不问归期 提交于 2019-12-11 06:53:43
问题 I am developing a native android app that run a backup operation every 30 mins. I am using AlarmManager for this purpose and it works fine. Here is the code I am using to start the alarm: public static void startSync(Context context) { alarmIntent = new Intent(context, AlarmReceiver.class); pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0); manager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // int interval = 3600000; int interval =30000 ; manager

android wakelock not released after getActiveNetworkInfo

ε祈祈猫儿з 提交于 2019-12-11 03:39:42
问题 I want to automatically check for an internet connection every x minutes and send data to a server. However, the following (minimal) code gives a warning in Eclipse, saying that the release() call is not always reached. PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, ""); wl.acquire(); // check active network ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context