Android 调用方法而不是调用活动
这是两个音频和视频队列。我要他们重复7次 但是for循环和while循环不起作用。看来所有的名誉都将同时被执行 我还能回忆起Android 调用方法而不是调用活动,android,Android,这是两个音频和视频队列。我要他们重复7次 但是for循环和while循环不起作用。看来所有的名誉都将同时被执行 我还能回忆起活动 但是我想要一种方法,一个接一个地多次(例如7次)调用音频和视频本身 感谢您的帮助 这是我代码的一部分: Public boolean dispatchTouchEvent(MotionEvent ev) { SharedPreferences appSettings = PreferenceManager.getDefaultSharedPre
活动
但是我想要一种方法,一个接一个地多次(例如7次)调用音频和视频本身
感谢您的帮助
这是我代码的一部分:
Public boolean dispatchTouchEvent(MotionEvent ev) {
SharedPreferences appSettings = PreferenceManager.getDefaultSharedPreferences(this);
boolean doAudio= appSettings.getBoolean("audioCue", true);
boolean doVideo= appSettings.getBoolean("videoCue", true);
String audioFreqS = appSettings.getString("audioFrequency", "400");
float audioFrequency = (float)Integer.parseInt(audioFreqS);
String audioLoudnessS = appSettings.getString("audioLoudness", "100");
float audioLoudness = ((float)Integer.parseInt(audioLoudnessS))/100.0f;
// determine whether estimation or cue mode is active
if (!currentlyEstimating) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// determine random timespan for cue(s)
initCueLength();
// use video cue, i.e. display colored block for the specified time
if (doVideo) {
switch (Integer.parseInt(appSettings.getString("cueBackgroundColor", "1"))) {
case 1:
videoLayout.setBackgroundColor(Color.WHITE);
break;
case 2:
videoLayout.setBackgroundColor(Color.RED);
break;
case 3:
videoLayout.setBackgroundColor(Color.GREEN);
break;
case 4:
videoLayout.setBackgroundColor(Color.BLUE);
break;
case 5:
videoLayout.setBackgroundColor(Color.YELLOW);
break;
default:
videoLayout.setBackgroundColor(Color.WHITE);
}
// after the delay specified for postDelayed, set background to black
Handler handler = new Handler();
handler.postDelayed(new Runnable()
{
public void run()
{
videoLayout.setBackgroundColor(Color.BLACK);
}
}, cueLength);
loopnum++;
}
if (doAudio) {
// TODO integrate sound playing
final SoundGenerator task=new SoundGenerator();
task.keepPlaying(true);
task.setLoudness(audioLoudness);
// start sound generator with the specified frequency (Hz)
task.execute(audioFrequency);
Handler handler = new Handler();
handler.postDelayed(new Runnable()
{
public void run()
{
task.keepPlaying(false);
}
}, cueLength);
}
}
播放音频和视频是很容易的,所以如果你只是做一个循环,你会得到并行播放7次的声音。您可能会在播放结束时触发repeat(重复),例如声音,通过一个递减计数器,并在计数器达到0时停止重复。您的意思是这样的吗?计数器=0;while(柜台)