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

View file

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