androidin-app-billingscreen-orientationandroid-billingplay-billing-library

Google Billing crash my app because change screen mode to portrate


I have standard billing client with clear architecture, my billing clieant does not know about activity. I Send to billing client activity like a param on his method no more. My app has screen mode = sensore landscape. I declare that on manifest and on BaseActivity.

Manifest

android:screenOrientation="sensorLandscape"

BaseActivity onCreate

   requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE

When i click on btn for buy some products on my App I have on some old device good working and on new device crash like Resources$NotFoundException. This is due to the fact that no resources were found for the portrait mode in which my application is currently located. I cannot understand why on some devices the shopping menu is called in landscape mode and on others in portrait mode. I tried to set the Landscape sensor in the client's billing methods, where I transfer the activity parameter, but it did not help. Most likely, you have to go to the library itself

com.android.billingclient:billing-ktx:6.0.0

When I click BUY my activity call onPause that crash LOG on picture enter image description here

TRY

open class BaseApplication : Application.ActivityLifecycleCallbacks {

    override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
        activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

    override fun onActivityStarted(activity: Activity) {
        activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

    override fun onActivityResumed(activity: Activity) {
        activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

    override fun onActivityPaused(activity: Activity) {
        activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

    override fun onActivityStopped(activity: Activity) {
        activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

    override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
        activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

    override fun onActivityDestroyed(activity: Activity) {
        activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
    }

}

Myaplication

class MyApplication: Application() {

    init {
        instance = this
    }

    companion object {
        private var instance: MyApplication? = null

        @JvmStatic
        fun getContext(): Context {
            return instance!!.applicationContext
        }
    }

    override fun onCreate() {
        super.onCreate()
        registerActivityLifecycleCallbacks(BaseApplication())
    }
}

but don't help


Solution

  • It is Google bug. Google billing client called on portrait screen mode. After Google billing library update to 6.0.1 version this bug is fixed. But on this link nothing information about this bug.