我正在实现MediaRecorder.OnInfoListener来切换活动,但是方法参数不接受View参数!我该怎么办?
这是源代码。
@Override
public void onInfo(MediaRecorder mr, int what, int extra) {
// TODO Auto-generated method stub
if( what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED)
{
stopRecording(View);//View cannot be resolved to variable
}
}
这里是stopRecoring用于切换另一个活动......
public void stopRecording(View v) {
Log.d(TAG, "stopRecording()");
assert this.mediaRecorder != null;
try {
this.mediaRecorder.stop();
timeSwapBuff += timeInMilliseconds;
customHandler.removeCallbacks(updateTimerThread);
Toast.makeText(this, R.string.saved, Toast.LENGTH_SHORT).show();
// we are no longer recording
flipCamera.setVisibility(View.VISIBLE);
captureImage.setVisibility(View.VISIBLE);
this.toggleButtons(false);
} catch (RuntimeException e) {
// the recording did not succeed
Log.w(TAG, "Failed to record", e);
if (this.file != null && this.file.exists() && this.file.delete()) {
Log.d(TAG, "Deleted " + this.file.getAbsolutePath());
}
return;
} finally {
this.releaseMediaRecorder();
}
if (this.file == null || !this.file.exists()) {
Log.w(TAG,
"File does not exist after stop: "
+ this.file.getAbsolutePath());
} else {
Log.d(TAG,
"Going to display the video: "
+ this.file.getAbsolutePath());
Intent intent = new Intent(this, VideoPlaybackActivity.class);
intent.setData(Uri.fromFile(file));
System.out.println("########Uri is: " + Uri.fromFile(file));
intent.putExtra("fromClass", "");
intent.putExtra("file_name", videoName);
super.startActivity(intent);
finish();
}
}
有什么想法吗?