Hi People,
I'm new to writing app for android. I've got program writing experience in vhdl, gnu make and tcl but not in the java/android language. This is a bit different compared to this others.
I would like to start simple and do the following:
Press a button and a the vibrator of the phone will be triggered in a certain pattern.
I know that if you say: vibrator.vibrate(pattern , 0); that it will repeat the pattern. But I would like to turn on and off the screen in that pattern too for example.
What would be the right way to do this?
Thanks a lot for you help!
I'm new to writing app for android. I've got program writing experience in vhdl, gnu make and tcl but not in the java/android language. This is a bit different compared to this others.
I would like to start simple and do the following:
Press a button and a the vibrator of the phone will be triggered in a certain pattern.
I know that if you say: vibrator.vibrate(pattern , 0); that it will repeat the pattern. But I would like to turn on and off the screen in that pattern too for example.
What would be the right way to do this?
Code:
package com.trick-design.simple_prog;
import android.app.Activity;
import android.os.Bundle;
import android.content.Context;
import android.os.Vibrator;
import android.view.View;
public class simple_prog extends Activity {
private long[] pattern = {100, 100, 300, 100, 900, 1050};
boolean vibrator_on = true;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
protected void onStart() {
super.onStart();
findViewById(R.id.vibrate_button).setOnClickListener(vibrate_click_listener);
}
View.OnClickListener vibrate_click_listener = new View.OnClickListener() {
public void onClick(View v) {
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(pattern , -1);
}
};
@Override
protected void onStop() {
super.onStop();
// The activity is no longer visible (it is now "stopped")
}
@Override
protected void onDestroy() {
super.onDestroy();
// The activity is about to be destroyed.
}
}
Thanks a lot for you help!