wakelock

GPS Location tracking even when app is closed(Not running in Background)/ScreenLocked

谁说我不能喝 提交于 2019-12-02 11:33:10
I want to track user location very similar to strava, even after the is closed. I tried AlarmManager but it's not giving me execution after every one minute Just using a Service as BiGGZ explained won't work in case the device enters sleep mode. The Service won't be killed though but your app won't get any CPU. Therefore you would have to acquire a partial Wakelock to prevent the device from entering sleep mode. @Override public void onCreate() { super.onCreate(); PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE); wakeLock = m.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,

Allow phone to vibrate when screen turns off

末鹿安然 提交于 2019-12-02 10:14:29
问题 I am looking for a way to allow my program to make the phone vibrate after the screen has turned off from timing out. I have done lots of research, and have not found something that works. I have looked at the PowerManager class and more specifically the WakeLock mechanism. From the sound of many posts, I would need to use the PARTIAL_WAKE_LOCK variable of the WakeLock class. PARTIAL_WAKE_LOCK - Wake lock that ensures that the CPU is running. However, I cannot get it to vibrate the phone when

AlarmManager working well in emulator but not in real device

冷暖自知 提交于 2019-12-02 08:13:13
this is my code for setting alarm: public void SetAlarm(Context context, int tag, long time){ AlarmManager am=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, Alarm.class); i.putExtra("position", tag); PendingIntent pi = PendingIntent.getBroadcast(context, tag, i, PendingIntent.FLAG_CANCEL_CURRENT); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+ time, pi); // Millisec * Second * Minute } this is my onRecieve methode: public void onReceive(final Context context, Intent intent){ PowerManager pm = (PowerManager) context.getSystemService

Android doze mode and foreground service

蹲街弑〆低调 提交于 2019-12-02 07:34:25
I read many questions here about doze mode like Android doze mode , Android N Doze mode - how to keep background download and processing? , Wakelock and doze mode and many others. But in many replies, opinions is different. I can't test it by myself (emulator does not support my processor, and my only test device is android 5.1). I would like to know the next situation. I have an activity, which controls the media player. On devices with android 6.0 and higher it wouldn't work as expected cause of doze mode. As many solutions says to prevent doze mode it should start a service in separate

Service pauses on screen lock

限于喜欢 提交于 2019-12-02 04:28:59
For testing purposes i have made a service that beeps every 1 minute. (No client-server interface yet). It beeps okay when the screen in on, but when it goes to sleep the beeping stops. I am making an application that has to periodically poll the a server for something. For this, I am trying to create a service that'll constantly be running in the background, poll the server every 1 min and then based on the reply from server it shall generate a task bar notification. I have a test activity with two buttons, 1 to start and the other to stop the service. And one service class named S_PS

How to keep android device from sleeping while plugged in

一世执手 提交于 2019-12-01 22:19:51
I'd like to keep the screen on whenever one of my Activities are running and the phone is plugged in to a power source. I know that Wakelocks are tricky, so I'm looking for an example or some documentation on how to accomplish this specific goal. hackbod Don't use wake locks for this -- just set and clear the window flag WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON based on whether the device is currently plugged in. You can set the flag with Activity.getWindow().addFlags() . So the code would be getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); A WakeLock isn't that

WakeLock not working

♀尐吖头ヾ 提交于 2019-12-01 21:26:42
I have a wake lock set up so that I can still hear the sound when the screen times out or I press the screen lock button. From what I can understand through reading online is that I only need a partial wake lock. Here is the code but it is not working. No logcat errors 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.View; import android.widget.ArrayAdapter; import android

Dim screen while user inactive

試著忘記壹切 提交于 2019-12-01 03:40:34
I have an app which is used for lets say 4 hours, but only every 5 minutes a user needs to make an input or read the screen. Putting the phone to sleep and locking the screen is a bit annoying. So I have two options: getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); which doesn't lock the screen but the screen is always bright, I would like to dim it while there is no activity. Just because of battery life span, or doesn't that matter that much for these 4 hours? a wake lock SCREEN_DIM_WAKE_LOCK which does as well what I want, but I was told rather to use option 1 above.

Activity Recognition does not work after phone goes asleep

耗尽温柔 提交于 2019-12-01 00:23:10
Disclaimer: this is not duplicate of Activity Recognition stops receiving updates when phone goes to standby(screen off state) because I'm already using that approach and it does not help. Problem: It seems that Activity Recognition service stops working and is not sending any updates when device goes asleep. It works OK (recognized activities are stored to sqlite) when device is not asleep but as soon as I press power button on HTC M8, nothing is stored from this moment until I wake up the device but pressing power button again. Some details how I'm doing activity recognition: Requesting

Battery optimizations (wakelocks) on Huawei EMUI 4.0+

送分小仙女□ 提交于 2019-11-30 20:21:29
Good day, situation: I'm developing Android application that serve as sport tracker/navigation app - so it require permanent connection to GPS and also permanent awake device. Recording is done every second. Current solution working for years is thanks to wakelocks that keep device awake. Doze mode in Android 6.0+ complicate situation, but it is not this case. On Huawei device is probably different type of optimization. Here is part of log: 10-10 10:33:18.462 1014-384 D/PFW.HwPFWAppWakeLockPolicy: getUidWakeLock uid: 10097 wakelock >= 10 mins 10-10 10:33:18.543 1014-384 D/PFW