Я попробовал поискать в Интернете, чтобы найти решение, но пока ничего не решает проблему. Вот некоторые решения, с которыми я столкнулся, но не помогли:
- Изменение режима запуска в AndroidManifest.xml на SingleTask >:
Код: Выделить всё
< /ол>
Код: Выделить всё
class MainActivity : FlutterActivity() {
private val CHANNEL = "app.channel.shared.data"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
handleIntent(intent)
}
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(intent)
}
private fun handleIntent(intent: Intent) {
if (Intent.ACTION_VIEW == intent.action && intent.data != null) {
val data: Uri? = intent.data
// Revised intent flags
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
// Process the deep link and send it to Flutter
if (data != null) {
handleDeepLink(data)
}
}
}
private fun handleDeepLink(data: Uri) {
flutterEngine?.let {
MethodChannel(it.dartExecutor.binaryMessenger, CHANNEL).invokeMethod("deeplink", data.toString())
} ?: run {
// Handle the case where the FlutterEngine is not initialized
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/788 ... on-android