This Android app captures an image and describes it using the Gemini API.
- Android Studio
- Minimum SDK: 24
- A Gemini API key from Google AI Studio
Add OkHttp in app/build.gradle:
implementation 'com.squareup.okhttp3:okhttp:4.12.0'Inside MainActivity.java:
private static final String API_KEY = "YOUR_API_KEY_HERE";Add this to AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />Build and install the app on a device or emulator that has a camera.
Tap Capture to open the camera. Take a photo, and a small thumbnail will appear in the ImageView.
Tap Gemini. The app will convert the image to Base64, build a JSON request, send the request to the Gemini API, and receive the description
The app will parse the description and output it in the TextView. Any errors (network issues, JSON parsing problems) will be shown in Logcat.