package com.example.broadcast;

import android.Manifest.permission;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class VibrateActivity extends Activity {
    private static final String ACTION_VIBRATE="com.example.VIBRATE";
    private static final String VIBRATE_DURATION="durationInMS";
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.vibrate);

        Button button = (Button) findViewById(R.id.vibrate);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                EditText et = (EditText) findViewById(R.id.duration);
                String durationString = et.getText().toString();
                int duration = Integer.parseInt(durationString);

                Intent intent =  new Intent(ACTION_VIBRATE);
                intent.putExtra(VIBRATE_DURATION, duration);
                sendBroadcast(intent, permission.VIBRATE);
            }
        });
    }
}
