In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of how to achieve a flashlight program in Android, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this Android article on how to achieve a flashlight program. Let's take a look at it.
After the development of the flashlight in iphone, I started the program on how to make the flashlight in Android. My cross-platform engine framework CloudBox has established the iphone version of the program, but I have no idea how to control the flash on the Android, so I made a small example of how to use Android to control the flash.
This code works in the Samsung Galaxy S2 test.
Public class CloudLed {boolean m_isOn; Camera m_isOn Camera; public boolean getIsOn () {return m_isOn;} public CloudLed () {m_isOn = false;} public void turnOn () {if (! m_isOn) {m_isOn = true Try {m_Camera = Camera.open (); Camera.Parameters mParameters; mParameters = m_Camera.getParameters (); mParameters.setFlashMode (Camera.Parameters.FLASH_MODE_TORCH); m_Camera.setParameters (mParameters) } catch (Exception ex) {} public void turnOff () {if (m_isOn) {m_isOn = false; try {Camera.Parameters mParameters; mParameters = m_Camera.getParameters () MParameters.setFlashMode (Camera.Parameters.FLASH_MODE_OFF); m_Camera.setParameters (mParameters); m_Camera.release ();} catch (Exception ex) {}}
I created a CloudLed class to encapsulate Camera again and only deal with the code related to the flash.
In Android, to enable the camera, you only need to use Camera.Open to enable it. After enabling it, you can get Camera.Parameters to set the parameters.
For the flashlight function we need, just set it to FLASH_MODE_TROCH
When you turn it off, just set it to FLASH_MODE_OFF and release it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.