Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Ionic send broadcast with intent and extra values #29

Open
yasser-mas opened this issue Jan 22, 2018 · 2 comments
Open

Ionic send broadcast with intent and extra values #29

yasser-mas opened this issue Jan 22, 2018 · 2 comments
Labels

Comments

@yasser-mas
Copy link

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);
@darryncampbell
Copy link
Owner

darryncampbell commented Jan 23, 2018

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.

@darryncampbell
Copy link
Owner

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 (b22421d)
  • 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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants