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

Published by inkskull on

Checkout java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation | Android Oreo

The problem seems to be happening when your target sdk is 28. So after trying out many options finally this worked.

<activity
            android:name=".activities.FilterActivity"
            android:theme="@style/Transparent"
            android:windowSoftInputMode="stateHidden|adjustResize" />

style:-

<style name="Transparent" parent="Theme.AppCompat.Light.NoActionBar">
     <item name="android:windowIsTranslucent">true</item>
     <item name="android:windowBackground">@android:color/transparent</item>
     <item name="android:windowIsFloating">true</item>
     <item name="android:windowContentOverlay">@null</item>
     <item name="android:windowNoTitle">true</item>
     <item name="android:backgroundDimEnabled">false</item>
 </style>

Note:parent=”Theme.AppCompat.Light.NoActionBar” is needed for api 28. Previously had something else at api 26. Was working great but started to give problem at 28. Hope it helps someone out here. EDIT: For some only by setting <item name="android:windowIsTranslucent">false</item> and <item name="android:windowIsFloating">false</item> worked.May be depends upon the way you implement the solution works.In my case it worked by setting them to true.

Registering Static Broadcast receiver in Oreo | Android 8 Registering Static Broadcast receiver

There are some Broadcast Limitations in Oreo, it no longer supports to registering broadcast receivers for implicit broadcasts in app manifest. And NEW_OUTGOING_CALL is one of them, read here

You can use PHONE_STATE action for your purpose as it hasn’t categorized as a implicit broadcasts yet

public class StateReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent) {
   // will trigger at incoming/outgoing call

    try {
        String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
        String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
        String outgoingNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    }
    catch (Exception e){
        e.printStackTrace();
    }
  }
}

In manifest,

        <receiver android:name=".StateReceiver">
        <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE" />
        </intent-filter>
        </receiver>

Also you need to add and check READ_PHONE_STATE permission

Categories: Android

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Social Media Auto Publish Powered By : XYZScripts.com