android-powermanager

What happens to connection with BLE device when Android goes in sleep mode

时光毁灭记忆、已成空白 提交于 2019-12-13 15:11:39
问题 What happens to connection with BLE device connection when Android goes in sleep mode? So if application establishes a connection with BLE device and then Android goes sleep, will the connection be maintained? Will the application be informed about disconnects or re-connection? 回答1: BLE is devided in two parts, physical layer and link layer implemented in the BLE controller (frontend) upper layers implemented on host side (Android system) both parts connect via the HCI interface. (Which you

Detect if user is currently present without receiver for ACTION_USER_PRESENT and ACTION_SCREEN_OFF

你离开我真会死。 提交于 2019-12-11 10:14:20
问题 Is there a way to detect if the user is currently present without listening for the ACTION_USER_PRESENT-event and its counterpart ACTION_SCREEN_OFF? I don't like to cache the last event in SharedPrefs, because I can't listen for ACTION_SCREEN_OFF using a receiver registered in the manifest. I want to avoid to implement a service that runs all the time just to get the ACTION_SCREEN_OFF-event. Because that service doesn't run anymore if my app crashes. PowerManager#isScreenOn() or PowerManager

Prevent USB_DEVICE_ATTACHED launching app after a reboot

谁说我不能喝 提交于 2019-12-11 07:16:06
问题 I have an activity listening for the USB_DEVICE_ATTACHED broadcast intent, which launches when the user plugs in my USB device and selects our app. My problem is the android host devices reboot themselves once a day (usually around 4am), at which point the attached USB_DEVICE_ATTACHED intent is also fired by itself. In this circumstance, I definitely don't want to launch my activity as it doesn't know how to close itself. How can I prevent that from happening? I tried to use the PowerManager

Android P Beta - AlarmManager Notifications not working

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 14:02:26
I'm testing my application on Android P beta release 4. My app's targetSdkVersion is 27 It has been observed that alarm manager notifications are not working as expected. I'm using below code to set the notifications - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, AlarmIntentBuilder.buildPendingIntent(context, uri)); } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis,

Android P Beta - AlarmManager Notifications not working

喜欢而已 提交于 2019-11-29 19:49:36
问题 I'm testing my application on Android P beta release 4. My app's targetSdkVersion is 27 It has been observed that alarm manager notifications are not working as expected. I'm using below code to set the notifications - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, AlarmIntentBuilder.buildPendingIntent(context, uri)); } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && Build.VERSION.SDK

Unlock the Screen Programmatically

落花浮王杯 提交于 2019-11-29 06:39:52
I have a share button in the GCM notification . On click of the share button, I need to launch share intent. Everything works perfectly. Only problem that I'm facing is Lollipop lock screen feature. When I click share button from lock screen, my intent dialog appears below the lock screen and user has to unlock the screen to see the dialog. I want to unlock the screen programatically, when share button is clicked. I tried with Power Manager, But all it's wakeClock flags are deprecated and WindowManager.LayoutParams.Flag_KEEP_SCREEN_ON is recommened to use. But I'm not using activity here. I'm

How do I avoid that my App enters optimization on Samsung devices

笑着哭i 提交于 2019-11-28 06:36:29
Smart manager kills an app that hasn't been used for 3 days. My app does some background work and hence, the user doesn't need to open it. What can I do so that it doesn't enter app optimization mode ( Android OS 5.0.2, 5.1.1) Sadly, there is currently no way to prevent this. The only thing you can do is instruct users to disable optimization for your app. I did some research about this myself not long ago, here are some links I saved that might be interesting for you https://news.samsung.com/global/smart-manager-the-way-to-keep-your-galaxy-smartphone-as-good-as-new-always http://developer

When does android device go to sleep mode?

半城伤御伤魂 提交于 2019-11-28 06:25:00
I was searching SO and web but i couldn't find sufficient answer for my particular question. Ok here we go: Every user can modify screen timeout on android. (when screen turns off when its idle for __ seconds/minutes - users choice ). But user can modify ONLY screen timeout and not when device goes actually to sleep. I found here what happens when device goes to sleep: (Really nice answer by CommonsWare) Android Sleep/Standby Mode Ok my question is simple. How do i know when my phone will go to sleep? Will it go to sleep immediately after turning screen off? Will it stay "awake" a while after