darryncampbell-cordova-plugin-intent
darryncampbell-cordova-plugin-intent copied to clipboard
Ionic send broadcast with intent and extra values
I don't know how to add intent in sendbroadcast and put extra array list of strings also adding FLAG_INCLUDE_STOPPED_PACKAGES and component to be like the below native code :
ArrayList<String> messageList = new ArrayList<String>();
messageList.add( "51541545" );
messageList.add("nbvnv");
final Intent intent =new Intent();
intent.setAction( "customReciver.sms.4gtss" );;
intent.putStringArrayListExtra("infoList", messageList);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
intent.setComponent(new ComponentName("com.example.mustafa.recieverapp","com.example.mustafa.recieverapp.MyBroadcastReceiver"));
sendBroadcast(intent);
Right now I am afraid that is not possible with this plugin: https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/blob/master/src/android/IntentShim.java#L164 .
I'm going to label this as an enhancement, if there is enough interest then I can add it.
OK, so I have been making some changes to the plugin over the past week or so and have some updates on this:
- flags are now possible, specify an array of integers corresponding to the flags you want (use the Android docs to see the integer values you need, for example FLAG_INCLUDE_STOPPED_PACKAGES is 32. This change is not on npm at the time of writing but is checked into github (https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent/commit/b22421d3fef74a6b724af93115d9606975eecf8a)
- You can specify the action of the intent using action: e.g. https://github.com/darryncampbell/plugin-intent-api-exerciser/blob/master/www/js/index.js#L66
- You can specify the component of the intent using component and giving it a correctly structured JSON object, e.g. https://github.com/darryncampbell/plugin-intent-api-exerciser/blob/master/www/js/index.js#L220
- You can NOT specify a StringArrayList extra and I probably will never add this as it is not possible to distinguish between a StringArrayList and a StringArray in JSON. Right now you can specify string extras and bundle extras, the latter being newly included in 0.1.1. I will change the label of this issue to 'limitation' or something similar to highlight the delta