This commit is contained in:
Harsh Bhikadia 2021-04-23 18:52:15 +05:30
parent 5e109bed8f
commit b369590279
2 changed files with 8 additions and 11 deletions

View file

@ -3,7 +3,6 @@ package com.bhikadia.receive_intent
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.annotation.NonNull
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
@ -47,9 +46,9 @@ class ReceiveIntentPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Strea
}
private fun handleIntent(intent: Intent, fromPackageName: String?) {
Log.e("ReceiveIntentPlugin", "intent: $intent")
Log.e("ReceiveIntentPlugin", "fromPackageName: $fromPackageName")
Log.e("ReceiveIntentPlugin", "intentMap: " + intentToMap(intent, fromPackageName))
//Log.e("ReceiveIntentPlugin", "intent: $intent")
//Log.e("ReceiveIntentPlugin", "fromPackageName: $fromPackageName")
//Log.e("ReceiveIntentPlugin", "intentMap: " + intentToMap(intent, fromPackageName))
if (initialIntent) {
initialIntentMap = intentToMap(intent, fromPackageName)
initialIntent = false
@ -62,8 +61,7 @@ class ReceiveIntentPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Strea
if (resultCode != null) {
if (data == null) {
activity?.setResult(resultCode)
}
else {
} else {
val json = JSONObject(data)
activity?.setResult(resultCode, jsonToIntent(json))
}

View file

@ -67,14 +67,14 @@ fun wrap(o: Any?): Any? {
}
try {
if (o is Collection<*>) {
Log.e("ReceiveIntentPlugin", "$o is Collection<*>")
//Log.e("ReceiveIntentPlugin", "$o is Collection<*>")
return JSONArray(o as Collection<*>?)
} else if (o.javaClass.isArray) {
Log.e("ReceiveIntentPlugin", "$o is isArray")
//Log.e("ReceiveIntentPlugin", "$o is isArray")
return toJSONArray(o)
}
if (o is Map<*, *>) {
Log.e("ReceiveIntentPlugin", "$o is Map<*, *>")
//Log.e("ReceiveIntentPlugin", "$o is Map<*, *>")
return JSONObject(o as Map<*, *>?)
}
if (o is Boolean ||
@ -92,8 +92,7 @@ fun wrap(o: Any?): Any? {
return o.toString()
}
} catch (e: Exception) {
Log.e("ReceiveIntentPlugin", e.message, e)
e.printStackTrace()
//Log.e("ReceiveIntentPlugin", e.message, e)
}
return null
}