This is a guide [using Tasker] to create a Zooper variable that shows Bluetooth status. It’s quite similar to creating the headphone variable I covered earlier, but a little bit more involved as it has to check if Bluetooth is connected as well as just on or off.
Zooper Widget bluetooth variable [req. tasker]
Posted: 2014/04/11 in Tasker, Zooper TutesTags: Bluetooth, zooper
Sending variables to Zooper from your native android app
Posted: 2014/04/08 in Android Development, Zooper TutesI recently developed Zooper Companion App which sends colour codes to Zooper Widget to be used in advanced parameters to create nice colour themes.
There are many ways that this can be used to increase the general awesomeness of zooper. For example Media utilities uses this to show the file path of coverart and general media information. The options for uses is really endless…
This is a quick tutorial on how to variables to Zooper via Intents. This tutorial does require a very low level of android development experience. Not much more than if you can create a hello world app though. In fact, I will build off the android developer Hello World tutorial.
If you want to follow this tutorial to a tee, then make your way through that tutorial first, then at the end, instead of just sending your message to a new activity, we will also sent it to Zooper as the variable #TMESSAGE#.
So we’ll assume you’ve got to the point where you’ve added an input text field and a button to start a new activity. All we’re going to be doing is adding to the MainAcrivity.java
You should have this in your MainActivity.java code:
/** Called when user clicks the Send button */ public void sendMessage(View view) { //Do something in response to button Intent intent = new Intent(this, DisplayMessageActivity.class); EditText editText = (EditText) findViewById(R.id.edit_message); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); }
What we’re going to do is add the intents to send the String ‘message’ to Zooper as well as the DisplayMessageActivity.
Do do this we need to define some intents that Zooper needs to be bundled with the intent in order for it to recognize them. This builds off zooper’s intent action TASKERVAR, which is the way that tasker is able to send variables to zooper. In doing so, all variable’s sent to zooper start with a T. So in the example below the VARIABLE is defined as TEST, so in Zooper it will be recognized as #TTEST#:
/** Called when user clicks the Send button */ //Setup zooper intents used to send message to zooper public static final String INTENT_ACTION = "org.zooper.zw.action.TASKERVAR"; public static final String BUNDLE_STRING_NAME = "org.zooper.zw.tasker.var.extra.STRING_VAR"; public static final String BUNDLE_STRING_VALUE = "org.zooper.zw.tasker.var.extra.STRING_TEXT"; public static final String BUNDLE_VERSION_CODE = "org.zooper.zw.tasker.var.extra.INT_VERSION_CODE"; public static final String BUNDLE_NAME = "org.zooper.zw.tasker.var.extra.BUNDLE"; //This is the name of the variable, plus a T at the beginning. So for this example #TTEST# public static final String VARIABLE = "TEST";
You can either define this variable while you’re defining all the other intents (as above), or you can simply replace the VARIABLE in the “b.putString(BUNDLE_STRING_NAME, VARIABLE);” with “TEST”. Either way works the same.
I use the former and define it before we get to the sendMessage code.
So once we’ve defined those intents, all we need to do is add some code to the sendMessage part of the code, so that it bundles those intents and sends them to Zooper to use. We do that by adding the following code:
Intent in = new Intent(INTENT_ACTION); Bundle b = new Bundle(); b.putInt(BUNDLE_VERSION_CODE, 1); b.putString(BUNDLE_STRING_NAME, VARIABLE); b.putString(BUNDLE_STRING_VALUE, message); in.putExtra(BUNDLE_NAME, b); sendBroadcast(in);
So after all that, the sendMessage part of your MainActivity.java code should look like this:
/** Called when user clicks the Send button */ //Setup zooper intents used to send message to zooper public static final String INTENT_ACTION = "org.zooper.zw.action.TASKERVAR"; public static final String BUNDLE_STRING_NAME = "org.zooper.zw.tasker.var.extra.STRING_VAR"; public static final String BUNDLE_STRING_VALUE = "org.zooper.zw.tasker.var.extra.STRING_TEXT"; public static final String BUNDLE_VERSION_CODE = "org.zooper.zw.tasker.var.extra.INT_VERSION_CODE"; public static final String BUNDLE_NAME = "org.zooper.zw.tasker.var.extra.BUNDLE"; //This is the name of the variable, plus a T at the beginning. So for this example #TTEST# public static final String VARIABLE = "TEST"; public void sendMessage(View view) { //Do something in response to button Intent intent = new Intent(this, DisplayMessageActivity.class); EditText editText = (EditText) findViewById(R.id.edit_message); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); //send message to zooper Intent in = new Intent(INTENT_ACTION); Bundle b = new Bundle(); b.putInt(BUNDLE_VERSION_CODE, 1); b.putString(BUNDLE_STRING_NAME, VARIABLE); b.putString(BUNDLE_STRING_VALUE, message); in.putExtra(BUNDLE_NAME, b); sendBroadcast(in); }
You can download a my sample project here.