|
...
|
...
|
@@ -8,6 +8,7 @@ import android.os.Bundle |
|
|
|
import android.util.Log
|
|
|
|
import io.flutter.plugin.common.MethodChannel
|
|
|
|
import io.flutter.plugin.common.MethodCall
|
|
|
|
import android.content.Intent
|
|
|
|
|
|
|
|
class MainActivity: FlutterActivity() {
|
|
|
|
|
|
...
|
...
|
@@ -30,6 +31,7 @@ class MainActivity: FlutterActivity() { |
|
|
|
|
|
|
|
// 这里要获取启动时的intent
|
|
|
|
val uri = intent.data
|
|
|
|
|
|
|
|
val paramsMap = mutableMapOf<String, String>()
|
|
|
|
if (uri != null) {
|
|
|
|
val set = uri.queryParameterNames
|
|
...
|
...
|
@@ -48,10 +50,36 @@ class MainActivity: FlutterActivity() { |
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
override fun onNewIntent(intent: Intent) {
|
|
|
|
super.onNewIntent(intent)
|
|
|
|
// flutter版本更新后使用 getFlutterEngine().getDartExecutor().getBinaryMessenger()代替 getFlutterView()
|
|
|
|
val channel = MethodChannel(getFlutterEngine()?.getDartExecutor()?.getBinaryMessenger(), CHANNEL)
|
|
|
|
|
|
|
|
// 这里要获取启动时的intent
|
|
|
|
val uri = intent.data
|
|
|
|
val paramsMap = mutableMapOf<String, String>()
|
|
|
|
if (uri != null) {
|
|
|
|
val set = uri.queryParameterNames
|
|
|
|
for (name in set) {
|
|
|
|
val value = uri.getQueryParameter(name)
|
|
|
|
paramsMap[name.toString()] = value.toString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
intentMap = paramsMap
|
|
|
|
|
|
|
|
channel.setMethodCallHandler { call, result ->
|
|
|
|
Log.i(TAG,intentMap.toString());
|
|
|
|
when (call.method) {
|
|
|
|
"getIntent" -> get_intent(call, result)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取intent
|
|
|
|
private fun get_intent(call: MethodCall, result: MethodChannel.Result) {
|
|
|
|
Log.i(TAG, "调用${call.method}方法")
|
|
|
|
result.success(intentMap)
|
|
|
|
intentMap.clear();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|