[Android Software Development] imso:
Q1. What are the available different forms of video encoding type available in android for user to choose from? Because i'm currently doing a video recording app which i wanted to use ListPreference to allow user to dynamically choose what type of encoding is available.

Q2. I wanted to know is there any easy way to retrieve video resolution on the actual phone? Because different phone has different phone resolution's compatibility, so i wanted to retrieve the resolution data and display the different resolutions dynamically into my ListPreference for user selection... Does it have to do with a method name "flatten()" i don't quite know what is the method... :confused: I'm kinna new in java/android, can someone guide me on how should i do that?

My mainActivity.java file

public class CameraTest extends Activity implements SurfaceHolder.Callback {

private static final String TAG = "Exception";

public static SurfaceView surfaceView;
public static SurfaceHolder surfaceHolder;
public static Camera MainCamera;
private static boolean previewRunning;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

surfaceView = (SurfaceView)findViewById(R.id.surface_camera);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);

surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//getparameters

Button btnStart = (Button) findViewById(R.id.button4);
btnStart.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
startService(new Intent(getApplicationContext(), ServiceRecording.class));
}
});

Button btnStop = (Button) findViewById(R.id.button5);
btnStop.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
stopService(new Intent(getApplicationContext(), ServiceRecording.class));
}
});

Button btnSetting = (Button) findViewById(R.id.button2);
btnSetting.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
startActivity(new Intent(getApplicationContext(), SettingActivity.class));
}
});
}

public static boolean ServiceStatus;
@Override
public void surfaceCreated(SurfaceHolder holder) {

if(ServiceRecording.recordingStatus)
{
stopService(new Intent(getApplicationContext(), ServiceRecording.class));

try {
Thread.sleep(4000);
}
catch (InterruptedException e) {
e.printStackTrace();
}

MainCamera = ServiceRecording.ServiceCamera;

startService(new Intent(getApplicationContext(), ServiceRecording.class));
}
else{

MainCamera = Camera.open();

if (MainCamera != null) {
Camera.Parameters params = MainCamera.getParameters();
params.setPreviewSize(320, 240);
params.setPreviewFormat(PixelFormat.JPEG);
MainCamera.setParameters(params);

try {
MainCamera.setPreviewDisplay(holder);
}

catch (IOException e)
{
e.printStackTrace();
}
MainCamera.startPreview();
previewRunning = true;
}
else {
Toast.makeText(getApplicationContext(), "Camera not available!", Toast.LENGTH_LONG).show();
finish();
}
}

if (previewRunning) {
MainCamera.stopPreview();
}

/*ServiceStatus = ServiceRecording.recordingStatus;
if(ServiceStatus == true)
{
stopService(new Intent(getApplicationContext(), ServiceRecording.class));

if (MainCamera != null) {
Camera.Parameters params = MainCamera.getParameters();
MainCamera.setParameters(params);
MainCamera.startPreview();
}
}*/
}

@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

}

@Override
public void surfaceDestroyed(SurfaceHolder holder){
MainCamera.stopPreview();
previewRunning = false;
MainCamera.release();
}
}

My Preference.xml file

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="Video">
<CheckBoxPreference
android:title="Audio"
android:defaultValue="True"
android:summary="Select w/o Audio"
android:key="AudioPref" />
<ListPreference
android:title="Video Encoder"
android:defaultValue="3gp"
android:summary="Select a video encoding type"
android:key="EncodingPref"
android:entries="@array/EncodingType"
android:entryValues="@array/updateEncodingType"
android:dialogTitle="Video Encoding Formats" />
<ListPreference
android:title="Video Resolution"
android:defaultValue="1"
android:summary="Select the video resolution"
android:key="ResolutionPref"
android:entries="@array/VideoResolution"
android:entryValues="@array/updateVideoResolution"
android:dialogTitle="Video Resolution" />
</PreferenceCategory>
</PreferenceScreen>