Overview
The Flashlight Extension allows you to control the device's flashlight without needing camera permission. This extension provides two simple functions to turn the flashlight on and off.
Installation
-
Download the
.aix
file of the Flashlight extension.
com.damiano.flashlight.aix (4.1 KB) -
Open your MIT App Inventor project.
-
Click on Extensions in the left-side menu.
-
Choose Import extension and select From my computer.
-
Upload the
.aix
file and click OK.
Components
This extension is a non-visible component and does not appear on the user interface.
Available Methods
1. TurnOnFlash
- Description: Turns the device's flashlight on.
- Usage:
Flashlight.TurnOnFlash()
- Example:
Use this block when a button is clicked to turn on the flashlight:- When Button1.Click:
- Call
Flashlight.TurnOnFlash
- Call
- When Button1.Click:
2. TurnOffFlash
- Description: Turns the device's flashlight off.
- Usage:
Flashlight.TurnOffFlash()
- Example:
Use this block when a button is clicked to turn off the flashlight:- When Button2.Click:
- Call
Flashlight.TurnOffFlash
- Call
- When Button2.Click:
Example Usage
ASd.aia (6.0 KB)
Here’s how to use the Flashlight extension in your MIT App Inventor project:
- Add the Flashlight Extension to your project.
- Drag and Drop two buttons (
Button1
andButton2
) onto the designer screen. - Configure the Blocks:
Button1
: When clicked, should turn on the flashlight usingFlashlight.TurnOnFlash()
.Button2
: When clicked, should turn off the flashlight usingFlashlight.TurnOffFlash()
.
Screenshot of Blocks Example
Create a simple app with two buttons to turn the flashlight on and off.
- Button1 (Turn On):
when Button1.Click
do
call Flashlight.TurnOnFlash
- Button2 (Turn Off):
when Button2.Click
do
call Flashlight.TurnOffFlash
Notes
- Permission: This extension does not require camera permission (
android.permission.CAMERA
), which makes it easier to use in applications where privacy concerns are an issue. - Compatibility: Ensure that the device supports flashlight operations and that it is running a version of Android compatible with the Camera2 API.
Changelog
- Version 1.0:
- Initial release with basic functionality to turn the flashlight on and off.
- Open Source Code:
flashlight.zip.aia (11.4 KB)
Fully made by ChatGPT