How to solve Permission Denial: reading com.android.providers.downloads.DownloadStorageProvider - android

I'm using react-native-document-picker to get file from android device and upload them. I was able to pick a file and upload normally but only from folder inside My File. If I pick a file in others directory, for example, Recent (the one display first when open the Document picker) the app would stop immidiately and display error:
Permission Denial: reading com.android.providers.downloads.DownloadStorageProvider uri content://com.android.providers.downloads.documents/document/msf:3239 from pid=19089, uid=10372 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
despite it is the same file storaged in My File.
I used react-native-image-crop-picker and was able to pick image in any directory.
Below is the code of my manifest file and document picker function:
---------------AndroidManifest----------------
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCeZH6swcDYvYWT78RhSAQYbE1m_Gt2VXs"/>
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
---------------DocumentPickerFunction----------------
let arrFile: FileUploadParam[] = [];
let pickFile = async () => {
DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],
}).then((file: any) => {
arrFile.push(
fileStorageService.createFileUploadParam(file.name, file.uri, false),
);
fileStorageService.uploadChatAttachs(arrFile).subscribe((result) => {
let urlArr: MessageAttach[] = [];
result.map((item: any) => {
urlArr.push({
name: item.name,
storage_filename: item.storage_filename,
url: item.url,
type: AttachType.FILE,
});
});
chatService
.sendAttachFileMessage('', urlArr, roomId)
.subscribe((message) => {});
console.log('Upload data', urlArr);
});
});
};

Related

how to merge these two AndroidManifest files

I am currently using this AndroidManifest in my project: Current Manifest, however I am trying to use this other AndroidManifest from a website in order to implement an image upload service : Manifest to add
I have been searching for answers but I haven't been able to merge these 2 files successfully. The Current Manifest picture of course is not the entirety of it, but I simply showed you the most important parts. Am I able to merge both packages, with both applications and activities?
current manifest
<manifest
package="org.briarproject.briar"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.bluetooth"/>
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<application
android:name="org.briarproject.briar.android.BriarApplicationImpl"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:logo="#mipmap/ic_launcher_round"
android:theme="#style/BriarTheme">
<activity
android:name="org.briarproject.briar.android.reporting.DevReportActivity"
android:excludeFromRecents="true"
android:exported="false"
manifest to add
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.simplifiedlearning.volleymysqlexample">
<!-- the internet permission -->
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Do you still want to merge them (or still are wondering how to do it, after reading other peoples comments) ?.
If so (you could have used a separate module or make a library), one way is like this:
I kept your old package name as the external main one
I made sure I had all permissions of both manifest's
I kept the new Activity's intent-filter (so it's the first Activity on launch)
You need to physically copy the new source code (directory/s) into your current source code
("net.simplifiedlearning.volleymysqlexample.MainActivity" meaning physically "...\net\simplifiedlearning\volleymysqlexample\MainActivity" {windows path convention})
Merging manifest's is quite a simple operation, merging resources can be a lot of work. Questions you have to ask yourself:
Do I need resources from the new project and copy/merge them into the current ?
(They may be many and incompatible, strings,layouts, styles and themes in particular but many more ...).
Is the build system of the new project merged into your project ?
Example resource directories (not to mention all the files):
res +
+---drawable-hdpi
+---drawable-land-hdpi
+---drawable-land-ldpi
+---drawable-land-mdpi
+---drawable-land-xhdpi
+---drawable-land-xxhdpi
+---drawable-land-xxxhdpi
+---drawable-mdpi
+---drawable-port-hdpi
+---drawable-port-ldpi
+---drawable-port-mdpi
+---drawable-port-xhdpi
+---drawable-port-xxhdpi
+---drawable-port-xxxhdpi
+---drawable-xhdpi
+---drawable-xxhdpi
+---layout
+---menu
+---mipmap-hdpi
+---mipmap-ldpi
+---mipmap-mdpi
+---mipmap-xhdpi
+---mipmap-xxhdpi
+---mipmap-xxxhdpi
+---values
+---xml
The merged manifest:
<manifest
package="org.briarproject.briar"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature android:name="android.hardware.bluetooth"/>
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<application
android:name="org.briarproject.briar.android.BriarApplicationImpl"
android:allowBackup="false"
android:icon="#mipmap/ic_launcher_round"
android:label="#string/app_name"
android:logo="#mipmap/ic_launcher_round"
android:theme="#style/BriarTheme">
<activity android:name="org.briarproject.briar.android.reporting.DevReportActivity">
android:label="#string/crash_report_title"
</activity>
<activity android:name="net.simplifiedlearning.volleymysqlexample.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
your code shows two differentes packages, anyway, merge several manifest is a gradle or IDE task:
"Your APK file can contain just one AndroidManifest.xml file, but your Android Studio project may contain several—provided by the main source set, build variants, and imported libraries. So when building your app, the Gradle build merges all manifest files into a single manifest file that's packaged into your APK."
source: https://developer.android.com/studio/build/manifest-merge.html

Unable to find explicit activity class {}; have you declared this activity in your AndroidManifest.xml,my android manifest file read like this

<-- I m getting this fatal error which occurred while trying to upload pictures for my app in the android studio.please help get rid of this error.whats the best solution? the error is: Unable to find explicit activity class {}; have you declared this activity in your AndroidManifest.xml -->>
----------
----------
: Unable to find explicit activity class {}; have you declared this
activity in your AndroidManifest.
<?XML version="1.0" encoding="utf-8"?>
<manifest XML ns:android="http://schemas.android.com/apk/res/android"
package="com.parse.starter" >
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="18"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk
android:minSdkVersion="15"
android:maxSdkVersion="23"/>
<application
android:name=".StarterApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data
android:name="com.parse.APPLICATION_ID"
android:value="#string/parse_app_id" />
<meta-data
android:name="com.parse.CLIENT_KEY"
android:value="#string/parse_client_key" />
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
You have to check a package where MainActivity is placed. It should be com.parse.starter. It seems MainActivity is in other place and you are getting an exception.
This can happen when you say copy and paste an activity instead of adding it via Android Studio. Basically it just means you'll need to add this line to your AndroidManifest.xml:
<activity android:name=".your-activity-class-name"></activity>

java.lang.SecurityException: Sending SMS message: uid 10063 does not have android.permission.SEND_SMS [duplicate]

This question already has answers here:
Android permission doesn't work even if I have declared it
(11 answers)
Closed 1 year ago.
Hi I am trying to get sending sms to work. However when I try it says that I dont have permission to send sms and I have moved it all over my manifest and it still doesn't work. what am i missing?
`
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flegmann.annoyingsms">
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" /
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name="com.flegmann.annoyingsms.MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Enables various aspects of handling messages -->
</application>
</manifest>
`
As of android M The user has to grant you these permissions by your application follow standards standard as defined #
https://developer.android.com/training/permissions/requesting.html

Permission Denial Issue even after adding the required permission in manifest file

Here is the Error Log:
Permission Denial: starting Intent { act=android.settings.WIFI_DISPLAY_SETTINGS cmp=com.android.settings/.Settings$WifiDisplaySettingsActivity } requires com.android.setting.permission.ALLSHARE_CAST_SERVICE
at android.os.Parcel.readException(Parcel.java:1472)
at android.os.Parcel.readException(Parcel.java:1426)
at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2329)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1426)
at android.app.Activity.startActivityForResult(Activity.java:3513)
at android.app.Activity.startActivityForResult(Activity.java:3474)
at android.app.Activity.startActivity(Activity.java:3716)
at android.app.Activity.startActivity(Activity.java:3684)
Manifest file with Permission:
<uses-sdk android:minSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.setting.permission.ALLSHARE_CAST_SERVICE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:exported="true" >
</activity>
<activity
android:name=".SplashScreenActivity1"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
if your app is having target API level 23 make sure user grants the permission before using them. See RunTimePermission
I hope you are testing this application on samsung device because this permission is only worked on samsung device. As per my knowledge such permission is not exists in the android permission list.
Below is the permission list from android.
http://developer.android.com/reference/android/Manifest.permission.html
Hope this will help you.

Is it possible to write to the sd card without a file picker on kitkat+

I want to delete files from the SD card root without a file picker.
After searching around for a couple of days,i haven't found a way to do this.But files apps ES file explorer have no problem,does anyone know why that is?
The closest thing i found would be this
How to use the new SD-Card access API presented for Lollipop? but i have to use a file picker
Manifest
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
<uses-permission android:name="ANDROID.PERMISSION.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="ANDROID.PERMISSION.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.GET_PACKAGE_SIZE"/>
<uses-permission android:name="android.permission.CLEAR_APP_CACHE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
You must provide us some source code and tell what you tried.
Check if you can create new empty files:
File newFile = new File("/storage/sdcard1/test");
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Edit after comment:
Add this in your manifest above application tag.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Categories

Resources