GeoFenceAppDemo is an Android app for demonstrating geo-fencing functionality, supporting Android 10+ (API 24 and above). The app uses Koin for dependency injection and integrates the Google Maps API for geofencing.
Add these permissions to AndroidManifest.xml for location access:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
Key Properties
- Namespace: com.dharmesh.geofencedemo
- Compile SDK: 35
- Application ID: com.dharmesh.geofencedemo
- Minimum SDK: 24
- Target SDK: 35
- Gradle Version: 8.6
- The
api_key
used in the project is provided in gradle.properties. - added firebase crashlytics in project to get crash details.
-
Geofence Transitions: The app handles three geofence transitions:
- Enter
- Dwell
- Exit
-
Dependency Injection: Uses Koin for ViewModel injection
-
Google Maps Integration: Supports geofencing on Google Maps
-
Firebase Crash Analytics: Uses for crash in App
-
Add below code in MainActivity class in onCreate function
val crashButton = Button(this) crashButton.text = "Test Crash" crashButton.setOnClickListener { throw RuntimeException("Test Crash") // Force a crash }
addContentView(crashButton, ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
-
you will get a crash when click on Test Crash button.
-
Clone the Repository: Clone the repository to your local machine.
git clone <repository_url>
-
Open the Project:: Open the project in Android Studio.
-
Add Google Maps API Key:: Add your Google Maps API key in the AndroidManifest.xml file.
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" />
- Add Broadcast Receiver: Add the following receiver configuration to your AndroidManifest.xml file.
<receiver
android:name=".receiver.GeofenceEventReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.location.Geofence" />
</intent-filter>
</receiver>
- Run the App: Run the app on an Android device or emulator.