This is the code from my MainActivity:
package com.simple.flashlight;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Camera;
import android.hardware.Camera.Parameters;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class Main extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_menue);
Button turnOnButtOn = (Button) findViewById (R.id.button1);
Button turnOnButtOff = (Button) findViewById (R.id.button2);
Camera mCam = Camera.open(); //here is an error
Parameters p = mCam.getParameters(); //here is an error
turnOnButtOn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View cameraButton){
//Turn ON
}
});
turnOnButtOff.setOnClickListener(new Button.OnClickListener(){
public void onClick(View cameraButton){
//Turn OFF
}
});
}
}
and this what I have in the manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.simple.flashlight"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<permission
android:name="android.permission.FLASHLIGHT"
android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
android:protectionLevel="normal" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Main"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
I am getting errors on Camera mCam = Camera.open(); and Parameters p = mCam.getParameters(); the errors are:
1. the method open() is undefined for type Camera.
2. the method getParameters() is undefined for type Camera.
I’m new to Android development, so maybe I have missed something really stupid,
Thanks in advance!
Delete the
import android.graphics.Camera;It’s confusing your calls and does not have an open() method.