android-8.0-oreo

Android 8.0 Oreo crash on focusing TextInputEditText

非 Y 不嫁゛ 提交于 2019-11-27 09:21:01
问题 After updating some of our devices to android 8.0 , upon focusing on a TextInputEditText field inside of a TextInputLayout , the app crashes with this Exception : Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.getBoundsOnScreen(android.graphics.Rect)' on a null object reference at android.app.assist.AssistStructure$WindowNode.(AssistStructure.java) at android.app.assist.AssistStructure.(AssistStructure.java) at android.app

How does Bitmap allocation work on Oreo, and how to investigate their memory?

喜夏-厌秋 提交于 2019-11-27 07:28:27
Background For the past years, in order to check how much heap memory you have on Android and how much you use, you can use something like: @JvmStatic fun getHeapMemStats(context: Context): String { val runtime = Runtime.getRuntime() val maxMemInBytes = runtime.maxMemory() val availableMemInBytes = runtime.maxMemory() - (runtime.totalMemory() - runtime.freeMemory()) val usedMemInBytes = maxMemInBytes - availableMemInBytes val usedMemInPercentage = usedMemInBytes * 100 / maxMemInBytes return "used: " + Formatter.formatShortFileSize(context, usedMemInBytes) + " / " + Formatter

How to register for ACTION_PACKAGE_ADDED and ACTION_PACKAGE_REMOVED on Android Oreo?

耗尽温柔 提交于 2019-11-27 06:21:25
问题 Looking at the latest Android Oreo release notes, it seems like only a handful of implicit broadcasts can be registered by the apps. ACTION_PACKAGE_ADDED and ACTION_PACKAGE_REMOVED is not among them. Is there a workaround for receiving these broadcasts? 回答1: From the docs: Apps that target Android 8.0 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest. An implicit broadcast is a broadcast that does not target that app specifically. For example,

tm.getDeviceId() is deprecated?

安稳与你 提交于 2019-11-27 05:17:05
I'm getting the IMEI and device Id's, so here I am getting a problem getDeviceId() is deprecated. TelephonyManager tm = (TelephonyManager) getSystemService(this.TELEPHONY_SERVICE); imei = tm.getDeviceId(); device = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID); getDeviceId() Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available. This method was deprecated in API level 26. Use (@link getImei} which returns IMEI for GSM or (@link getMeid} which returns MEID for CDMA

Notifications fail to display in Android Oreo (API 26)

半城伤御伤魂 提交于 2019-11-27 04:10:40
I get this message when trying to display a notification on Android O. Use of stream types is deprecated for operations other than volume control The notification is straight from the example docs, and displays fine on Android 25. Per the comments on this Google+ post : those [warnings] are currently expected when using NotificationCompat on Android O devices ( NotificationCompat always calls setSound() even if you never pass in custom sound). until the Support Library changes their code to use the AudioAttributes version of setSound , you'll always get that warning. Therefore there's nothing

Broadcast receiver registered in manifest not getting called in Android Oreo

坚强是说给别人听的谎言 提交于 2019-11-27 04:07:07
问题 I have registered following receiver which is not getting called in Android Oreo but works on lower version devices. <receiver android:name=".common.receiver.ConsultReceiver" android:exported="false"> <intent-filter> <action android:name="APP_STARTED" /> <action android:name="APP_STARTED_FROM_ORGANIC" /> </intent-filter> </receiver> Any help would be appreciated? 回答1: In general, you cannot use an implicit Intent (e.g., one with just an action string) for a broadcast on Android 8.0+. Your

How can I reliably simulate touch events on Android without root (like Automate and Tasker)?

混江龙づ霸主 提交于 2019-11-27 03:34:28
问题 How can I reliably simulate touch events on Android (without rooting) from Java outside my app which runs as a background service? While this question has been asked before, most answers utilise ADB . (such as How to simulate touch events on Android device?) https://github.com/chetbox/android-mouse-cursor offers a good solution using Accessibility, but is not very reliable as not all views respond to it, and games do not respond at all most of the time. private void click() {

java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation

两盒软妹~` 提交于 2019-11-27 02:58:49
I am facing the problem while retrieving the contacts from the contact book in Android 8.0 Oreo java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation I am trying to get the contact in my activity from the phone contact book and it works perfect for Lollipop, Marshmallow, Nougat, etc but it will gives me the error for Oreo like this please help me. My code is here below. Demo Code :- private void loadContacts() { contactAsync = new ContactLoaderAsync(); contactAsync.execute(); } private class ContactLoaderAsync extends AsyncTask<Void, Void, Void> { private

ProgressDialog is deprecated [duplicate]

孤人 提交于 2019-11-27 02:47:40
问题 This question already has an answer here: ProgressDialog is deprecated.What is the alternate one to use? 17 answers Since the ProgressDialog is deprecated from the Android version O, I'm still finding a better way out to do my task. The task is to move from my activity to the fragment. Everything is working fine but the progressdialog is not visible. I've tried implementing it but... the progressdialog doesn't work. It seems the progressbar would work but still not working. I need a

Android support library 27, Fragment update?

ε祈祈猫儿з 提交于 2019-11-27 02:08:37
问题 Since I updated my project to SDK version 27 and gradle plugins for the support library to version 27.0.0 I needed to change my code. With 26.1.0 I can just use getContext() (with Kotlin context ) in my Fragment ( android.support.v4.app ) and I have no nullability issues, but since I use Kotlin I have a problem with version 27.0.0 , all my context calls did not work anymore, I needed a safety operator, like context!! , but since I personally find it to be a hustle to do that every time I just