How to manage installation from Unknown Sources in Android Oreo?

For starters, your application needs to declare a targetSdkVersion of 26 (API level of Android Oreo) or higher in your build.gradle or AndroidManifest.xml for all this to work. Then on to answer the questions above: How to check whether I’m allowed to request a package install? You can check this using getPackageManager().canRequestPackageInstalls() anywhere in your … Read more

Runtime exception Android O with boot_completed

Here are some options that I outlined in a blog post: Workaround #1: startForegroundService() Your BroadcastReceiver that receives the ACTION_BOOT_COMPLETED broadcast could call startForegroundService() instead of startService() when on Android 8.0+: import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Build; public class OnBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Intent i=new … Read more

Different notification sound not working in Oreo

Problem: It seems Notification Channel issue. Solution: Either you should create separate channel, or you should delete your own channel. Strategy: 1) Create separate channel: You may select this strategy if you want to persist multiple channels along with various configuration for your app. To create separate channel, just provide unique channel ID while creating … Read more

Android O – Detect connectivity change in background

Second edit: I’m now using firebase’s JobDispatcher and it works perfect across all platforms (thanks @cutiko). This is the basic structure: public class ConnectivityJob extends JobService{ @Override public boolean onStartJob(JobParameters job) { LogFactory.writeMessage(this, LOG_TAG, “Job created”); connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { connectivityManager.registerNetworkCallback(new NetworkRequest.Builder().build(), networkCallback = new ConnectivityManager.NetworkCallback(){ // -Snip- }); }else{ … Read more

Setting up Gradle for api 26 (Android)

Have you added the google maven endpoint? Important: The support libraries are now available through Google’s Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup. Add the endpoint to your build.gradle file: allprojects { repositories { jcenter() maven { url ‘https://maven.google.com’ } … Read more

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

In android Oreo (API 26) you can not change orientation for Activity that have below line(s) in style <item name=”android:windowIsTranslucent”>true</item> or <item name=”android:windowIsFloating”>true</item> You have several way to solving this : 1) You can simply remove above line(s) (or turn it to false) and your app works fine. 2) Or you can first remove below … Read more

PendingIntent is not working on Android O

Never use an implicit Intent when an explicit Intent will do. Android O helps enforce this by banning the receipt of implicit Intent broadcasts from manifest-registered receivers. Step #1: Remove the <intent-filter> from your <receiver> (which also means that you could get rid of android:exported=”false”, as that is now the default value) Step #2: Replace … Read more

Oreo BroadcastReceiver SMS Received not working

Previously I was requesting for -Manifest.permission.READ_SMS which didn’t worked then I changed the permissions to – Manifest.permission.RECEIVE_SMS then it started working in oreo and I also specified the receiver in manifest I don’t know whether that helped or not but this made the day for me public static void requestPermissionForReadSMS(Fragment fragment) { // if (fragment.shouldShowRequestPermissionRationale(Manifest.permission.READ_SMS)) … Read more

LocalNotification with AlarmManager and BroadcastReceiver not firing up in Android O (oreo)

Android O are pretty new to-date. Hence, I try to digest and provide as accurate possible information. From https://developer.android.com/about/versions/oreo/background.html#broadcasts Apps that target Android 8.0 or higher can no longer register broadcast receivers for implicit broadcasts in their manifest. Apps can use Context.registerReceiver() at runtime to register a receiver for any broadcast, whether implicit or explicit. … Read more

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

Looks like your app was killed by Linux OOM killer. Game developers and other people, who actively use native memory, see that happen all the time. Enabling kernel overcommit together with lifting heap-based restrictions on Bitmap allocation may result in the picture you see. You can read a bit about overcommit here. Personally I would … Read more