Sun*_*Sun 6 java android shake
我正在使用它与Shake一起工作,这对我来说很好,但我想在用户摇动他们的设备时启动应用程序,请参阅下面的代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
transcript=(TextView)findViewById(R.id.transcript);
scroll=(ScrollView)findViewById(R.id.scroll);
shaker=new Shaker(this, 1.25d, 500, this);
}
@Override
public void onDestroy() {
super.onDestroy();
shaker.close();
}
public void shakingStarted() {
Log.d("ShakerDemo", "Shaking started!");
transcript.setText(transcript.getText().toString()+"Shaking started\n");
scroll.fullScroll(View.FOCUS_DOWN);
}
public void shakingStopped() {
Log.d("ShakerDemo", "Shaking stopped!");
transcript.setText(transcript.getText().toString()+"Shaking stopped\n");
scroll.fullScroll(View.FOCUS_DOWN);
}
Run Code Online (Sandbox Code Playgroud)
所以这是我的问题,如何通过摇动我的设备启动应用程序?
| 归档时间: |
|
| 查看次数: |
3299 次 |
| 最近记录: |