This is a simple Android application that demonstrates how to use the WebView component to create an APK that launches directly to a specified URL. The app essentially wraps a web application in a native Android container, providing a seamless mobile experience.
- WebView Integration: Uses Android's WebView component to display web content
- JavaScript Support: Enabled for full web application functionality
- Progress Indicator: Shows loading progress while the web page loads
- Back Navigation: Handles back button presses to navigate within the WebView
- Error Handling: Displays error messages if the web page fails to load
- Media Playback: Allows media playback without requiring user gesture
The app uses a WebView component that loads a specified URL when the app launches. The main functionality is implemented in MainActivity.java:
// The URL to load when the app starts
startWebView("https://ap-iwa.com/ProMobileV3");- WebView Setup: The WebView is configured with JavaScript enabled and media playback support
- WebViewClient: Handles URL loading, page completion, and error handling
- WebChromeClient: Manages permissions for web content
- Progress Bar: Shows loading progress to improve user experience
To change the URL that the app loads, modify line 22 in app/src/main/java/com/support/webapp_to_webview/MainActivity.java:
startWebView("https://your-custom-url.com"); // Replace with your desired URLTo customize the app icon, follow these steps:
-
Prepare Your Icon: Create your icon image in the following formats:
- PNG format
- Multiple sizes: 48x48, 72x72, 96x96, 144x144, 192x192, 512x512 pixels
- Both square and round versions (for round icons)
-
Replace Icon Files: Replace the existing icon files in the following directories:
app/src/main/res/mipmap-hdpi/- 72x72 pixelsapp/src/main/res/mipmap-mdpi/- 48x48 pixelsapp/src/main/res/mipmap-xhdpi/- 96x96 pixelsapp/src/main/res/mipmap-xxhdpi/- 144x144 pixelsapp/src/main/res/mipmap-xxxhdpi/- 192x192 pixels
-
File Names: Use these naming conventions:
ic_launcher.png- Square iconic_launcher_round.png- Round iconic_launcher_foreground.png- Foreground icon (for adaptive icons)
-
Update Manifest: The app icon is referenced in
app/src/main/AndroidManifest.xml:android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round"
-
Alternative Method: You can also use Android Studio's built-in Asset Studio:
- Right-click on
app/src/main/res/ - Select "New" → "Image Asset"
- Choose "Launcher Icons"
- Import your custom image
- Generate the icons
- Right-click on
To change the app name displayed on the device, modify app/src/main/res/values/strings.xml:
<string name="app_name">Your Custom App Name</string>-
Clone the repository:
git clone <repository-url> cd webview-btm
-
Open in Android Studio or build from command line:
./gradlew assembleRelease
-
Find the APK: The built APK will be located at:
app/build/outputs/apk/release/app-release.apk
- Android API level 21+ (Android 5.0+)
- Internet permission (already configured)
- Target URL must be accessible from the device
The app requires the following permission:
INTERNET- To load web content
- Web page not loading: Check your internet connection and ensure the target URL is accessible
- JavaScript not working: JavaScript is enabled by default, but some websites may require additional permissions
- App crashes: Ensure the target URL is valid and the device has internet connectivity
This project is provided as an example for educational purposes.