Question

I have been attempting to send variable data directly from SL4A to Minimalistic Text Widget using sendBroadcastIntent much like how I can send variables to Tasker (Using code I found on the SL4A google groups)

Unfortunately my understanding of intents is a little lax and I have found locating tutorials specifically in relation to SL4A almost impossible.

The SL4A makeintent API Reference

The minimalistic Test Intent example

The code I have attempted to use:

import Android
droid = Android()

activity = "com.twofortyfouram.locale.intent.action.FIRE_SETTING"
extras = {'de.devmil.minimaltext.locale.extras.VAR_NAME': "Test"; "de.devmil.minimaltext.locale.extras.VAR_TEXT" : "Passed"}
packagename = 'de.devmil.minimaltext'
classname = 'de.devmil.minimaltext.locale.LocaleFireReceiver'
intent = droid.makeIntent(activity, None, None, extras, None, packagename, classname).result
droid.sendBroadcastIntent(intent)
Was it helpful?

Solution

The reason your original code did not work is because you are using ; instead of , to split the name/value pairs when you create the dictionary called extras.

Wrong Way:

extras = {'de.devmil.minimaltext.locale.extras.VAR_NAME':"Test" ; "de.devmil.minimaltext.locale.extras.VAR_TEXT" : "Passed"}

Correct Way:

extras = {'de.devmil.minimaltext.locale.extras.VAR_NAME':"Test" , 'de.devmil.minimaltext.locale.extras.VAR_TEXT' : "Passed"}

You can learn more about using dictionaries here: http://www.tutorialspoint.com/python/python_dictionary.htm

OTHER TIPS

I got it working finally! From this Stackoverflow answer

import android

droid = android.Android()

activity = 'com.twofortyfouram.locale.intent.action.FIRE_SETTING'
extras = {}
extras['de.devmil.minimaltext.locale.extras.VAR_NAME'] = 'test'
extras['de.devmil.minimaltext.locale.extras.VAR_TEXT'] = 'Passed'

packagename =  'de.devmil.minimaltext'
classname = 'de.devmil.minimaltext.locale.LocaleFireReceiver'

intent = droid.makeIntent(activity, None, None, extras, None, packagename, classname).result

droid.sendBroadcastIntent(intent)

That said I am unsure as to where I have gone wrong in my initial code. If anyone would care to chime in and point out where the hell I have gone wrong

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top