10
10
import com .facebook .react .bridge .*;
11
11
12
12
import java .io .Console ;
13
+ import java .util .Set ;
14
+ import java .util .Iterator ;
13
15
14
16
/**
15
17
* Created by poberwong on 16/6/30.
@@ -56,7 +58,27 @@ public void startActivity(ReadableMap params, final Promise promise){
56
58
}
57
59
getReactApplicationContext ().startActivityForResult (intent , 12 , null ); // 暂时使用当前应用的任务栈
58
60
} catch (Exception e ) {
59
- promise .reject ("Could not open intent" );
61
+ promise .reject ("ERROR" , "Could not open intent" );
62
+ }
63
+ }
64
+
65
+ @ ReactMethod
66
+ public void startActivityOnlyIntent (ReadableMap params , final Promise promise ) {
67
+ this .promise = promise ;
68
+ try {
69
+ Intent intent = new Intent (params .getString (ATTR_DATA ));
70
+ if (params .hasKey (TAG_EXTRA )) {
71
+ intent .putExtras (Arguments .toBundle (params .getMap (TAG_EXTRA )));
72
+ }
73
+ if (params .hasKey (ATTR_FLAGS )) {
74
+ intent .addFlags (params .getInt (ATTR_FLAGS ));
75
+ }
76
+ if (params .hasKey (ATTR_CATEGORY )) {
77
+ intent .addCategory (params .getString (ATTR_CATEGORY ));
78
+ }
79
+ getReactApplicationContext ().startActivityForResult (intent , 12 , null ); // 暂时使用当前应用的任务栈
80
+ } catch (Exception e ) {
81
+ promise .reject ("ERROR" , "Could not open intent" );
60
82
}
61
83
}
62
84
@@ -68,10 +90,26 @@ public void onActivityResult(Activity activity, int requestCode, int resultCode,
68
90
if (requestCode != 12 ) {
69
91
return ;
70
92
}
71
- WritableMap params ;
93
+ WritableMap params = Arguments . createMap () ;
72
94
Bundle extras = data .getExtras ();
73
95
74
- params = Arguments .fromBundle (extras );
96
+ Set <String > keys = extras .keySet ();
97
+ Iterator <String > it = keys .iterator ();
98
+ Log .e ("LGC" ,"Dumping Intent start" );
99
+ while (it .hasNext ()) {
100
+ String key = it .next ();
101
+ if (extras .get (key ) instanceof String ) {
102
+ params .putString (key , (String ) extras .get (key ));
103
+ }
104
+
105
+ if (extras .get (key ) instanceof Integer ) {
106
+ params .putInt (key , (Integer ) extras .get (key ));
107
+ }
108
+
109
+ Log .e ("LGC" , "[" + key + "=" + extras .get (key ) + "]" );
110
+ }
111
+
112
+ // params = Arguments.fromBundle(extras);
75
113
76
114
this .promise .resolve (params );
77
115
0 commit comments