Infinite loop after intent, after upgrading to Android 14 in Samsung Z Fold 5

193 Views Asked by At

so i have a splash screen activity which lead to welcome activity after 1s, it's working fine on other device except this Samsung z fold 5 which just getting an android 14 update and One UI 6. i've already tried running on avd with android 14 and it's also working fine.

on that device, after splash activity, it keeps opening blank white page over and over again, in logcat i only found this warning logcat when blank white page opened

i've tried changing intent destination to another activity but its still the same, but when i change the destination to splash activity again its works.

all helps are apreciated. Thank You

manifest for splash activity

<activity
   android:launchMode="singleInstance"
   android:name=".ui.SplashActivity"
   android:exported="true">
   <intent-filter>
      <action android:name="android.intent.action.MAIN" />
      <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
</activity>

Splash Activity

class SplashActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.ne_activity_splash)
        setStatusBarGradient(this)

        val myLocale = Locale(paperPref.getLang().toString())
        val res = resources
        val dm = res.displayMetrics
        val conf = res.configuration
        conf.locale = myLocale
        res.updateConfiguration(conf, dm)
        onConfigurationChanged(conf)

    }

    private fun timerSplash() {
        object : CountDownTimer(1000, 1000) {
            override fun onFinish() {
                    val appUpdateManager = AppUpdateManagerFactory.create(this@SplashActivity)
                    val appUpdateInfoTask = appUpdateManager.appUpdateInfo
                    appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
                        if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
                            && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
                        ) {
                            updateDialog()
                        } else {
                            doIntent()
                        }
                    }

                    appUpdateInfoTask.addOnFailureListener {
                        doIntent()
                    }
            }

            override fun onTick(millisUntilFinished: Long) {}
        }.start()
    }

    private fun updateDialog() {
        ConfirmMessage(
            this@SplashActivity,
            getString(R.string.app_not_update),
            getString(R.string.app_not_update_desc),
            "confirm_data.json",
            getString(R.string.update),
            getString(R.string.later),
            object : FGCallback {
                override fun onCallback() {
                    val appPackageName: String = packageName

                    try {
                        startActivity(
                            Intent(
                                Intent.ACTION_VIEW,
                                Uri.parse("market://details?id=$appPackageName")
                            )
                        )
                    } catch (anfe: ActivityNotFoundException) {
                        startActivity(
                            Intent(
                                Intent.ACTION_VIEW,
                                Uri.parse("https://play.google.com/store/apps/details?id=$appPackageName")
                            )
                        )
                    }
                }
            },
            object : FGCallback {
                override fun onCallback() {
                    finish()
                }
            }
        )
    }

    companion object {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        fun setStatusBarGradient(activity: Activity) {
            val window = activity.window
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
            window.statusBarColor = ContextCompat.getColor(activity, android.R.color.white)
            window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
        }
    }

    private fun doIntent(){
        val intent = Intent(this@SplashActivity, WelcomeActivity::class.java)
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
        startActivity(intent)
    }

    override fun onResume() {
        super.onResume()

        val uri:Uri? = intent.data

        if(uri != null) {
            if(uri.toString().contains("referralcode"))
                paperPref.setLaunchUrl(uri.toString())
            else if(uri.toString().contains("notification"))
                paperPref.setLaunchUrl(uri.toString())
            else if(uri.toString().contains("event"))
                paperPref.setLaunchUrl(uri.toString())
        }

        timerSplash()
    }
}
0

There are 0 best solutions below