博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android onnewintent home,android - OnCreate fires twice from onNewIntent - Stack Overflow
阅读量:5109 次
发布时间:2019-06-13

本文共 1611 字,大约阅读时间需要 5 分钟。

I am using deep link, launchMode="singleTask". If there is an instance of my activity everything works fine: only onNewIntent is called. But if there is no instance, firstly onCreate is called, then onNewIntent and again onCreate. That is why, the screen flickers. What is the problem? I removed all code, and only logged the events. But the same behavior is observed.

android:name="uz.avtobank.MainActivity"

android:configChanges="keyboardHidden|orientation|screenSize"

android:launchMode="singleTask"

android:screenOrientation="nosensor"

android:theme="@style/SplashActivityTheme"

android:windowSoftInputMode="adjustResize|stateHidden">

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)

setTheme(R.style.AppTheme)

setContentView(R.layout.activity_main)

val host = NavHostFragment.create(R.navigation.nav_graph_main)

supportFragmentManager.beginTransaction()

.replace(R.id.container, host)

.setPrimaryNavigationFragment(host)

.commit()

logMessage("onCreate ${intent.action}")

}

@SuppressLint("DefaultLocale")

override fun onNewIntent(intent: Intent?) {

super.onNewIntent(intent)

logMessage("onNewIntent ${intent.action}")

handleIntent(intent)

}

private fun handleIntent(intent: Intent) {

if (intent.action != Intent.ACTION_VIEW)

return

try {

findNavController(R.id.container).handleDeepLink(intent)

} catch (e: IllegalStateException) {

} catch (e: IllegalArgumentException) {

}

setIntent(intent)

}

The following appears on the log:

There is instance: onNewIntent

There is no instance: onCreate, onNewIntent, onCreate

The same happens evene if I remove handleIntent method.

转载地址:http://lejdv.baihongyu.com/

你可能感兴趣的文章
距离公式汇总以及Python实现
查看>>
设计模式之装饰者模式
查看>>
一道不知道哪里来的容斥题
查看>>
Blender Python UV 学习
查看>>
window添加右键菜单
查看>>
入手腾龙SP AF90mm MACRO
查看>>
Window7上搭建symfony开发环境(PEAR)
查看>>
Linux内核态、用户态简介与IntelCPU特权级别--Ring0-3
查看>>
第23月第24天 git命令 .git-credentials git rm --cached git stash clear
查看>>
java SE :标准输入/输出
查看>>
一些方便系统诊断的bash函数
查看>>
jquery中ajax返回值无法传递到上层函数
查看>>
css3之transform-origin
查看>>
[转]JavaScript快速检测浏览器对CSS3特性的支持
查看>>
Master选举原理
查看>>
[ JAVA编程 ] double类型计算精度丢失问题及解决方法
查看>>
小别离
查看>>
微信小程序-发起 HTTPS 请求
查看>>
WPF动画设置1(转)
查看>>
基于node/mongo的App Docker化测试环境搭建
查看>>