FileDocCategorySizeDatePackage
TestInteractionActivity.javaAPI DocAndroid 5.1 API3929Thu Mar 12 22:22:44 GMT 2015com.android.test.voiceinteraction

TestInteractionActivity

public class TestInteractionActivity extends android.app.Activity implements View.OnClickListener

Fields Summary
static final String
TAG
android.app.VoiceInteractor
mInteractor
android.widget.Button
mAbortButton
android.widget.Button
mCompleteButton
Constructors Summary
Methods Summary
public voidonClick(android.view.View v)

        if (v == mAbortButton) {
            VoiceInteractor.AbortVoiceRequest req = new VoiceInteractor.AbortVoiceRequest(
                    "Dammit, we suck :(", null) {
                @Override
                public void onCancel() {
                    Log.i(TAG, "Canceled!");
                }

                @Override
                public void onAbortResult(Bundle result) {
                    Log.i(TAG, "Abort result: result=" + result);
                    getActivity().finish();
                }
            };
            mInteractor.submitRequest(req);
        } else if (v == mCompleteButton) {
            VoiceInteractor.CompleteVoiceRequest req = new VoiceInteractor.CompleteVoiceRequest(
                    "Woohoo, completed!", null) {
                @Override
                public void onCancel() {
                    Log.i(TAG, "Canceled!");
                }

                @Override
                public void onCompleteResult(Bundle result) {
                    Log.i(TAG, "Complete result: result=" + result);
                    getActivity().finish();
                }
            };
            mInteractor.submitRequest(req);
        }
    
public voidonCreate(android.os.Bundle savedInstanceState)


    
        
        super.onCreate(savedInstanceState);

        if (!isVoiceInteraction()) {
            Log.w(TAG, "Not running as a voice interaction!");
            finish();
            return;
        }

        setContentView(R.layout.test_interaction);
        mAbortButton = (Button)findViewById(R.id.abort);
        mAbortButton.setOnClickListener(this);
        mCompleteButton = (Button)findViewById(R.id.complete);
        mCompleteButton.setOnClickListener(this);

        // Framework should take care of these.
        getWindow().setGravity(Gravity.TOP);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);

        mInteractor = getVoiceInteractor();
        VoiceInteractor.ConfirmationRequest req = new VoiceInteractor.ConfirmationRequest(
                "This is a confirmation", null) {
            @Override
            public void onCancel() {
                Log.i(TAG, "Canceled!");
                getActivity().finish();
            }

            @Override
            public void onConfirmationResult(boolean confirmed, Bundle result) {
                Log.i(TAG, "Confirmation result: confirmed=" + confirmed + " result=" + result);
                getActivity().finish();
            }
        };
        mInteractor.submitRequest(req);
    
public voidonDestroy()

        super.onDestroy();
    
public voidonResume()

        super.onResume();