package com.example.testandroid; import com.voicecontrolapp.klets.api.KletsPluginApi; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; public class PluginActionReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle resultExtras = getResultExtras(true); Bundle parameters = intent.getBundleExtra(KletsPluginApi.EXTRA_PARAMETERS); // Lets check if we have something to repeat. if (!parameters.containsKey("TEXT_TO_REPEAT")) { // The user didn't said the text to repeat. We tell to KLets to ask for it. setResultCode(KletsPluginApi.ACTION_RESULT_ASK_PARAM); resultExtras.putString(KletsPluginApi.EXTRA_PARAMETER_ID, "TEXT_TO_REPEAT"); // Quit and wait for the next invocation, that will have the needed parameter. return; } String textToRepeat = parameters.getString("TEXT_TO_REPEAT"); // Setting the result Bundle and result code for this BroadcastReceiver execution. setResultCode(KletsPluginApi.ACTION_RESULT_OK); // We just tell to KLets to say back what the user said, setting it to the message in the result bundle. resultExtras.putString(KletsPluginApi.EXTRA_MESSAGE, textToRepeat); } }