workPro Documentation
The WorkPro app now fully supports file downloads from WebView with automatic permission handling during installation and runtime.
<!-- For Android 9 and below - Write access to public storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29" />
<!-- For Android 10-12 - Read media files from storage -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<!-- For Android 13+ - Read specific media types without broad storage permission -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<!-- Download notifications without user interaction -->
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
DownloadListener.onDownloadStart() is triggered/Android/data/com.workpro.app/files/Download/) - NO permission needed/Downloads/) - Requires WRITE_EXTERNAL_STORAGE permissionDownloadManager serviceSettings > Apps > WorkPro > Files > DownloadFile Manager > Downloads| Android Version | Location | Permission |
|---|---|---|
| 13+ | /Android/data/com.workpro.app/files/Download/ |
Not needed (app-specific) |
| 10-12 | /Android/data/com.workpro.app/files/Download/ |
Not needed (app-specific) |
| 9 and below | /storage/emulated/0/Download/ |
WRITE_EXTERNAL_STORAGE |
When user installs the APK, Android shows these permissions:
User can grant or skip these permissions at installation time.
If user skipped permissions at install time:
// Triggered when user clicks download link
webView.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
handleDownload(url, userAgent, contentDisposition, mimetype, contentLength);
}
});
handleDownload() - Checks permissionsrequestDownloadPermissions() - Requests if neededstartDownload() - Executes download using DownloadManagerprivate boolean hasDownloadPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// Android 10+ - no permission needed
return true;
} else {
// Android 9 and below - check WRITE_EXTERNAL_STORAGE
return ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED;
}
}
Create a download link in your PHP/HTML:
<a href="https://yourserver.com/files/document.pdf" download>Download PDF</a>
Click the link in the app
Grant permission when prompted
File downloads to app Downloads folder
Notification shows completion
App-Specific Storage (Android 10+)
Public Storage (Android 9 and below)
Permission Best Practice
User clicks download link
↓
App checks Android version
↓
Android 10+? → Download starts immediately
↓
Android 9 or below?
↓
Has WRITE_EXTERNAL_STORAGE permission?
├─ YES → Download starts
└─ NO → Show permission dialog
↓
User grants? → Download starts
↓
User denies? → Show error message
app/src/main/AndroidManifest.xml - Permissions declaredapp/src/main/java/com/workpro/app/MainActivity.java - Download handling codeapp/src/main/java/com/workpro/app/WorkProApplication.java - Global app configuration