I have an application, where i have a video player, with videos. If i keep my finger on the screen for more than 0,4 seconds, it finishs this activity, starts the recorder activity, and automatically starts recording. My question is: can i make the second activity recognise when i take my finger off the screen, so that is would stop recording?
This is called when i keep the screen pressed:
Intent i = new Intent(VideoPlayerActivity.this, VideoRecorderActivity.class);
Bundle extras = new Bundle();
extras.putInt("mode", VideoRecorderModes.SEND_ALL_MODE);
extras.putInt("index", index);
extras.putInt("touches", 2);
i.putExtras(extras);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
mPreview.getHolder().removeCallback(VideoPlayerActivity.this);
mPreview = null;
startActivity(i);
VideoPlayerActivity.this.finish();
This is called in my second activity, after the camera is ready:
touches = getIntent().getExtras().getInt("touches");
if (touches == 1) {
mySurfaceView.setPressed(true);
recordButton.setEnabled(false);
okButton.setEnabled(false);
recordButton.setImageResource(R.drawable.shutter_pressed);
startTime = System.currentTimeMillis();
timer = new Timer();
timer.schedule(new TimerDisplayTask(), 0, 500);
startRecording();
touches = 0;
System.out.println("----------------here----------");
}
This is the SurfaceView onTouch method for the surface view from the second activity:
mySurfaceView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.i(TAG, "event : " + event.getAction() + "||is?: " + isRecording);
Log.i(TAG, "touches:" + touches);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
//DO NOTHING
break;
case MotionEvent.ACTION_UP:
if (touches == 1 && isRecording) {
Log.i(TAG, "touch up");
timer.cancel();
timer.purge();
if (isRecording) {
mySurfaceView.setEnabled(false);
Log.i("VideoRecorder blabla", "touche enabled record, ok ,surface: " + recordButton.isEnabled() + "| " + okButton.isEnabled() + "|" + mySurfaceView.isEnabled());
stopRecording();
recordButton.setImageResource(R.drawable.shutter);
touches = 0;
}
}
break;
}
return false;
}
});