Android Studio & Flashlight App

AndroidStudioWhile thinking about my new project, my first though was: “I will try development for Android.”

After some research I’ve found Google’s compilation of tools called Android Studio, which is preffered for a newcomer in discussions a lot. It’s based on popular JetBrain’s IntelliJ IDEA. There is also Eclipse, which is although very good tool. But I find it too complicated. You need to set everything by hand, find the right plugins, then install and setup them.

You can find Android studio download link together with installing instructions here. You should be able to install all of required items by following the guide on the link.

I’ve choosen to write a simple flashlight as a first application, just to see how things works.

I was (again) surprised by limitations of Java. I was tired to see the functions been named properties. I mean getSomething() and setSomething(string value) instead of something = “test”. But even after I was able to get my application work on my Samsung Galaxy Note II, some of my friends reported, they’re not able to run the application on Note III and others.

I was actually been able to debug a code in computer, while looking at the UI in mobile phone. For this, you need to setup your mobile phone to enable USB debugging.

Speaking of flashlight APP, you’re here able to see the code, download the project and compiled APK. I’ll always try to provide you with all the sources I’ll come up with.

private void turnOn()
{
  disablePhoneSleep();
  if(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH) && getCamera() != null) {
  Camera.Parameters p = mCamera.getParameters();
  p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
  mCamera.setParameters(p);
  // save some battery
  setBrightness((float)0.01);
}else
{
  // the next best thing
  setBrightness((float)1);
}

This is pretty much the main function of the flashlight. I was a bit dissapointed, that I’ve not gained the access to the LED intensity, so there is not much you can do about it.

Here you can download whole android studio project, so you can build on top of it, or just play.

I’m actually using that as my personal flashlight app, because it does everything I wanted flashlight to do, and nothing else. So You can download the APK, which you can directly install into your android phone. Please share your thoughs in comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *