I followed a tutorial online about how to create a simple app that can switch on and off your phone's cam-light.
<manifest....>
<uses-permission android:name = "android.permission.CAMERA"/>
<uses-feature android:name = "android.hardware.camera"/>
</manifest>
This is in android manifest. The problem: it crashes when I press the ON button (made by me, in application)
Stack Trace:
07-17 22:27:13.990: E/AndroidRuntime(1775): FATAL EXCEPTION: main
07-17 22:27:13.990: E/AndroidRuntime(1775): java.lang.NullPointerException
07-17 22:27:13.990: E/AndroidRuntime(1775): at com.example.salpa.MainActivity$1.onClick(MainActivity.java:33)
07-17 22:27:13.990: E/AndroidRuntime(1775): at android.view.View.performClick(View.java:4204)
07-17 22:27:13.990: E/AndroidRuntime(1775): at android.view.View$PerformClick.run(View.java:17355)
07-17 22:27:13.990: E/AndroidRuntime(1775): at android.os.Handler.handleCallback(Handler.java:725)
Another strange thing: when I install the app, there are no details about what permissions is requiring.
"The application can acces the following on your phone:" and there's nothing. (despite the permissions in tutorial where it shows that the application needs permision to Camera.)
Can someone please help me, thanks.
setContentView(R.layout.activity_main);
Button aprinde =(Button)findViewById(R.id.aprinde);
//Button sting = (Button)findViewById(R.id.sting);
cameraObj = Camera.open();
aprinde.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view){
Camera.Parameters cameraParams = cameraObj.getParameters();
cameraParams.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
cameraObj.setParameters(cameraParams);
cameraObj.startPreview();
}
} );