android-wake-lock

Start activity even when screen is turned off

微笑、不失礼 提交于 2019-12-07 08:11:27
I'm trying to start an activity with an alarm. The PendingIntent starts a receiver and the receiver starts the activity. My current issue is that the activity starts in the background and it's impossible to hear the alarm sound. Most of the flags from older SO questions are deprecated for Oreo and newer devices. Does anyone have a good approach how to handle this? Thank you in advance Alarm creation: alarmManager.setExact(AlarmManager.RTC_WAKEUP, intervalFinished, pendingIntent) Receiver class OnAlarmReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) {

Alarm Manager not working at specific given time interval

雨燕双飞 提交于 2019-12-07 06:49:17
问题 Hi I am using alarm Manager for specific time interval for 3 minutes and I started monitoring. It worked for sometimes and suddenly I noticed there is irregular time interval which is not correct! You can see in attached log where at "20-Jul-2016 12:22:03 pm" time varies! I connected the phone and turned off the screen and monitored! where for every 3 minutes, i hit the server and gets the response as 1. But at one time, it takes 5 minutes to hit the server! Why this strange issue happened?

Check if onStop is called from user interaction, or screen dimming

柔情痞子 提交于 2019-12-07 03:46:28
问题 I have a media player that stops playing whenever the user closes the app, either by pressing the home button, using the back button or simply opening another app. To get this behavior, I added an onStop() to my main activity which tells my MediaPlayer (which is in a service) to stop playing music. However, I would like the music to keep playing whenever the screen gets dimmed, either by using the power button to turn the screen off, or just by the screen auto dimming. Right now the player

BroadcastReceiver wake lock needed if only AsyncTask is executed?

。_饼干妹妹 提交于 2019-12-06 19:19:27
I have got a class, which extends from BroadcastReceiver and gets called from AlarmManager . In the onReceive method I execute an AsyncTask , which fetches some data from the internet and stores the data in the local database of the application. Do I need to acquire wakelock with: @Override public void onReceive(Context context, Intent intent) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, ""); mWakeLock.acquire(); // execute AsyncTask } private void asyncTaskDone() { mWakeLock.release(); } in order

How to make an android app run in background when the screen sleeps?

僤鯓⒐⒋嵵緔 提交于 2019-12-06 13:53:40
问题 I am developing a Tracking app, which keeps tracks of the user by getting his current location for every 3 secs. I am able to fetch the lat long values when the screen is on. but when the screen sleeps. i am unable to fetch the datas. CODE: @Override public void onLocationChanged(Location location) { mLastLocation = location; if (mCurrLocationMarker != null) { mCurrLocationMarker.remove(); } latitude = location.getLatitude(); longitude = location.getLongitude(); latLngcurrent = new LatLng

Does service.startForeground imply wakelock?

只愿长相守 提交于 2019-12-05 21:13:20
Question I am wondering if we need to aquire the WakeLock or if the service.startForeground() command does that anyway for us? I didn't find anything in the documentation. Goal We want to remove unnesessary stuff which might slow down the service start as we want to start capturing the sensor data as soon as possible and as the service might be restarted frequently. Context We're developing an Android library to capture sensor data with ~ 200 Hz for up to a couple of hours (research environment). Right now we aquire a WakeLock and start the capturing service as ForegroundService to make sure

BroadcastReceiver, Service and Wakelock

别来无恙 提交于 2019-12-05 15:47:44
im receiving an intent in broadcast receiver and then i start service to do more work. now what if the device is sleep and this happen, do i have to get Wakelock (AlarmManger?), and why do i need it? does my service will stop running if the device goes to sleep without getting a wakelock. now what if the device is sleep and this happen, do i have to get Wakelock (AlarmManger?), and why do i need it? If the device is asleep to begin with, you will not be "receiving an intent in broadcast receiver", because the device is asleep. do i have to get Wakelock (AlarmManger?), and why do i need it? You

Alarm Manager not working at specific given time interval

寵の児 提交于 2019-12-05 08:28:15
Hi I am using alarm Manager for specific time interval for 3 minutes and I started monitoring. It worked for sometimes and suddenly I noticed there is irregular time interval which is not correct! You can see in attached log where at "20-Jul-2016 12:22:03 pm" time varies! I connected the phone and turned off the screen and monitored! where for every 3 minutes, i hit the server and gets the response as 1. But at one time, it takes 5 minutes to hit the server! Why this strange issue happened? Here is code. public void startAt3() { Intent alarmIntent = new Intent(ActivityTracking.this,

Check if onStop is called from user interaction, or screen dimming

时光总嘲笑我的痴心妄想 提交于 2019-12-05 07:23:50
I have a media player that stops playing whenever the user closes the app, either by pressing the home button, using the back button or simply opening another app. To get this behavior, I added an onStop() to my main activity which tells my MediaPlayer (which is in a service) to stop playing music. However, I would like the music to keep playing whenever the screen gets dimmed, either by using the power button to turn the screen off, or just by the screen auto dimming. Right now the player also stops playing when the screen dims, meaning that the onStop() method also gets called then. How can

How to make an android app run in background when the screen sleeps?

夙愿已清 提交于 2019-12-04 20:13:01
I am developing a Tracking app, which keeps tracks of the user by getting his current location for every 3 secs. I am able to fetch the lat long values when the screen is on. but when the screen sleeps. i am unable to fetch the datas. CODE: @Override public void onLocationChanged(Location location) { mLastLocation = location; if (mCurrLocationMarker != null) { mCurrLocationMarker.remove(); } latitude = location.getLatitude(); longitude = location.getLongitude(); latLngcurrent = new LatLng(location.getLatitude(), location.getLongitude()); Toast.makeText(context,String.valueOf(latitude)+" "