2012-12-15 40 views
0

我想创建一个Tasker插件。在Tasker中使用变量

一切都很好,工作得很好。

resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE,PluginBundleManager.generateBundle(getApplicationContext(),message)); 

resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB,generateBlurb(getApplicationContext(), message)); 

setResult(RESULT_OK, resultIntent); 

问题是当我想用这个代码来获得,例如电池电量:

我可以配置一个String要在我的应用程序通过使用EditActivity这个代码,下面的例子发送,所以我说:

resultIntent.putExtra("net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS",com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB); 

但应用程序无法正常工作,我得到一个字符串%BATT作为结果,该变量不会被替换......

因为我还没有找到一个例如,我会很高兴得到一些帮助,使其工作。

回答

2

哎哟,我笨:

public static Bundle generateBundle(final Context context,final String message, boolean variable) { 
    final Bundle result = new Bundle(); 
    result.putInt(BUNDLE_EXTRA_INT_VERSION_CODE, 
       Constants.getVersionCode(context)); 
    result.putString(BUNDLE_EXTRA_STRING_MESSAGE, message); 

    result.putString("net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS",BUNDLE_EXTRA_STRING_MESSAGE); 
    return result; 
} 
+0

工作就像一个魅力,我编辑的编辑活动,而不是PluginBundleManager。傻我。谢谢! – KickAss