本文介绍了SL4A广播的意图,极简主义文本组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图可变数据直接从SL4A发送到简约文字模组使用sendBroadcastIntent很像我怎么能变量发送到塔斯克(使用code我在谷歌SL4A发现组)

不幸的是我的意图的理解是有点松懈,我发现明确的定位有关教程SL4A几乎是不可能的。

<一个href=\"http://wiki.devmil.de/tiki-index.php?page=Set%20Minimalistic%20Text%20variables%20from%20your%20own%20app\"相对=nofollow>极简测试意图

在code我试图使用:

  Android的进口
机器人=的Andr​​oid()活动=com.twofortyfouram.locale.intent.action.FIRE_SETTING
演员= {'de.devmil.minimaltext.locale.extras.VAR_NAME:测试; de.devmil.minimaltext.locale.extras.VAR_TEXT:通过}
包名='de.devmil.minimaltext
类名='de.devmil.minimaltext.locale.LocaleFireReceiver
意图= droid.makeIntent(活动,无,无,演员,无,软件包名,类名)。结果
droid.sendBroadcastIntent(意向)


解决方案

你原来的code没有工作的原因是因为你使用; 而不是当你创建字典称为额外分裂名称/值对。

错误方式:

 演员= {'de.devmil.minimaltext.locale.extras.VAR_NAME:测试; de.devmil.minimaltext.locale.extras.VAR_TEXT:通过}

正确方法:

 演员= {'de.devmil.minimaltext.locale.extras.VAR_NAME:测试,de.devmil.minimaltext.locale.extras.VAR_TEXT:通过 }

您可以了解更多关于这里使用的词典:

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)
解决方案

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

这篇关于SL4A广播的意图,极简主义文本组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 06:48