This Question have 3 answers right now.

I have a few errors in android that I do not understand, how do I fix them?

By : Mira
Source: Stackoverflow.com
Question!
import android.app.Activity;

import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Camera;
import android.view.SurfaceHolder;



public class MainActivity extends Activity {

private SurfaceHolder mHolder;
private Camera mCamera;

public MainActivity(Context context, Camera camera) {
    super(context);
    mCamera = camera;
}


 private boolean checkCameraHardware(Context context) {
    if     (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        return true;
    } else
        return false;
}

public static Camera getCameraInstance() {
    Camera c = null;
    try {
        c = Camera.Open();
    } catch (Exception e) {
    }
    return c;
} 

} I am having trouble with errors like when I type

public MainActivity(Context context, Camera camera) {
    super(context);
    mCamera = camera;  

It says that "Activity() in Activity can not be applied to (android.Context.context.)"

And also when I type

public static Camera getCameraInstance() {
    Camera c = null;
    try {
        c = Camera.Open();
    } catch (Exception e) {
    }
    return c;
}

It says: "Cannot resolve method .Open" Which from my research Camera.Open() is a method.

By : Mira


Answers

Activities are instantiated by the operating system, so there's no reason you build a constructor. Beside this, Activity does not have a constructor with parameters, so you cannot call super(some_object).

Camera class does not have a static method Open(). It does not have static methods at all...

By : Francesco


This has to do with the fact that and short-circuits, and returns the truthy value instead of True or False.

In:

7 >= 77 and 7

7 >= 77 equates to False, so the second operand of and is never evaluated, so it becomes False.

In:

7 >= 7 and 77

7 is equal to 7 (obviously), so the second operand of and is evaluated. Since 77 is truthy, it's what's returned.



You need a logical condition in the while. Perhaps

program.toUpperCase().equals("Y")
By : nicomp



How to install new Android Studio extensions to IntelliJ IDEA

Will you recommend beginners to use Android Studio? [closed]

I can't install/launch Android Studio for Windows 7 64 bit [duplicate]

Android Studio / Intellij new project wizard

Android Studio - SDK is out of date or is missing templates

Does Android Studio support Maven?

Android Studio - Issue with Android SDK on Windows 7

Android Studio: Use AndroidAnnotations

Problems importing project into Android Studio regarding ActionBarSherlock

Can't start Android studio

Can't create new project in Android Studio on Mac OS [closed]

Android studio isn't opening on Windows

Video about I have a few errors in android that I do not understand, how do I fix them?