我的应用程序具有在Android 11中停止工作的共享功能,我不知道为什么。它适用于任何Android
外部SD卡中的应用程序文件夹是/store/58ED-1620/Android/data/com.floritfoto.apps.ave/
。在这个文件夹里,我有一堆其他文件夹。
如果我尝试共享文件/storage/58ED-1620/Android/data/com。floritfoto。应用程序。ave/ornitologia/MyTracks/ave\u 140321\u 103008。csv,比如通过WhatsApp,文件不会发送,这是logcat(
18:26:08.468 15827-15827/? W/adbd: timeout expired while flushing socket, closing
18:26:09.472 803-1100/? E/BufferQueueProducer: [com.floritfoto.apps.ave/com.floritfoto.apps.xvf.FileChooser$_13168#1](id:323000009a3,api:0,p:-1,c:803) disconnect: not connected (req=1)
18:26:09.472 13168-14775/com.floritfoto.apps.ave W/libEGL: EGLNativeWindowType 0x708d001ec0 disconnect failed
18:26:09.495 736-758/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:26:09.498 736-758/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:26:09.501 1117-1257/? W/ActivityTaskManager: Tried to set launchTime (0) < mLastActivityLaunchTime (53651559)
18:26:09.504 1117-1257/? W/WindowManager: Execute app transition: mNextAppTransition=TRANSIT_ACTIVITY_OPEN, displayId: 0 Callers=com.android.server.wm.RootWindowContainer.executeAppTransitionForAllDisplay:2586 com.android.server.wm.ActivityStackSupervisor.reportResumedActivityLocked:2225 com.android.server.wm.ActivityRecord.completeResumeLocked:5646 com.android.server.wm.ActivityStack.minimalResumeActivityLocked:1212 com.android.server.wm.ActivityStackSupervisor.realStartActivityLocked:1135
18:26:09.512 5471-5471/? W/ChooserActivity: Ignoring intent's EXTRA_TITLE, deprecated in P. You may wish to set a preview title by using EXTRA_TITLE property of the wrapped EXTRA_INTENT.
18:26:09.512 1117-1379/? W/PkgPredictorService: background app without no launcher icon android for.uid: 1000 userId: 0
18:26:09.513 5471-5471/? E/ActivityThread: Failed to find provider info for com.samsung.android.app.sharestar.ShareStarProvider
18:26:09.560 1117-3258/? E/IntervalStats: Unable to parse usage stats package 1041
18:26:09.560 1117-3258/? E/IntervalStats: Unable to parse usage stats package 1520
18:26:09.560 1117-3258/? E/IntervalStats: Unable to parse usage stats package 1997
18:26:09.618 13168-14876/com.floritfoto.apps.ave E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/MyTracks/ave_140321_103008.csv from pid=5471, uid=1000 requires the provider be exported, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:841)
at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:758)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:684)
at android.content.ContentProvider$Transport.query(ContentProvider.java:239)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:106)
at android.os.Binder.execTransactInternal(Binder.java:1190)
at android.os.Binder.execTransact(Binder.java:1159)
18:26:09.618 5471-5471/? W/ChooserActivity: Could not load (content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/MyTracks/ave_140321_103008.csv) thumbnail/name for preview. If desired, consider using Intent#createChooser to launch the ChooserActivity, and set your Intent's clipData and flags in accordance with that method's documentation
18:26:09.619 2498-3360/? W/NearbySharing: Ignore registering DIRECT_SHARE_SERVICE send surface, due to disabled scanning mediums. [CONTEXT service_id=194 ]
18:26:09.619 2498-3360/? W/NearbySharing: NearbySharingService call registerSendSurface returned nonzero status code for calling package com.google.android.gms: STATUS_DISABLED [CONTEXT service_id=194 ]
18:26:09.643 1117-1145/? E/WindowManager: win=Window{a0df760 u0 com.floritfoto.apps.ave/com.floritfoto.apps.xvf.FileChooser EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.ActivityRecord.destroySurfaces:5183 com.android.server.wm.ActivityRecord.destroySurfaces:5164 com.android.server.wm.WindowState.onExitAnimationDone:5570 com.android.server.wm.WindowStateAnimator.onAnimationFinished:332 com.android.server.wm.WindowState.onAnimationFinished:6035 com.android.server.wm.-$$Lambda$dwJG8BAnLlvKNGuDY9U3-haNY4M.onAnimationFinished:2 com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$SurfaceAnimator:112
18:26:09.668 5471-5471/? W/View: requestLayout() improperly called by com.android.internal.widget.RecyclerView{d6a7c8a VFED..... ......ID 0,0-1289,1011 #102047e android:id/resolver_list} during layout: running second layout pass
18:26:09.671 13168-14876/com.floritfoto.apps.ave E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/MyTracks/ave_140321_103008.csv from pid=5471, uid=1000 requires the provider be exported, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:841)
at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:758)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:684)
at android.content.ContentProvider$Transport.query(ContentProvider.java:239)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:106)
at android.os.Binder.execTransactInternal(Binder.java:1190)
at android.os.Binder.execTransact(Binder.java:1159)
18:26:09.672 5471-5471/? W/ChooserActivity: Could not load (content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/MyTracks/ave_140321_103008.csv) thumbnail/name for preview. If desired, consider using Intent#createChooser to launch the ChooserActivity, and set your Intent's clipData and flags in accordance with that method's documentation
18:26:09.714 803-1100/? E/BufferQueueProducer: [com.floritfoto.apps.ave/com.floritfoto.apps.xvf.FileChooser$_13168#0](id:323000009a1,api:0,p:-1,c:803) disconnect: not connected (req=1)
18:26:09.714 13168-14775/com.floritfoto.apps.ave W/libEGL: EGLNativeWindowType 0x708cee8e80 disconnect failed
18:26:09.729 736-758/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:26:09.730 736-758/? E/HYPER-HAL: [Request.cpp]acquire(): Request:: id : 648112, No Resource to set
18:26:09.730 2339-2339/? E/pageboostd: Received HALT command code 2
18:26:09.730 736-758/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:26:09.731 803-823/? E/BufferQueueProducer: [android/com.android.internal.app.ChooserActivity$_5471#0](id:323000009a4,api:0,p:-1,c:803) disconnect: not connected (req=1)
18:26:09.731 5471-6304/? W/libEGL: EGLNativeWindowType 0x708cf88930 disconnect failed
18:26:09.749 13168-14938/com.floritfoto.apps.ave E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/MyTracks/ave_140321_103008.csv from pid=5471, uid=1000 requires the provider be exported, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:841)
at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:758)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:684)
at android.content.ContentProvider$Transport.query(ContentProvider.java:239)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:106)
at android.os.Binder.execTransactInternal(Binder.java:1190)
at android.os.Binder.execTransact(Binder.java:1159)
18:26:09.749 5471-5471/? W/ChooserActivity: Could not load (content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/Android/data/com.floritfoto.apps.ave/ornitologia/MyTracks/ave_140321_103008.csv) thumbnail/name for preview. If desired, consider using Intent#createChooser to launch the ChooserActivity, and set your Intent's clipData and flags in accordance with that method's documentation
18:26:09.888 5471-6332/? E/SharedPreferencesImpl: Couldn't create directory for SharedPreferences file /data/system/shared_prefs/com.android.internal.app.ChooserActivity.xml
18:26:10.028 727-1236/? E/Sensors: Sensor : Meta event
18:26:10.030 736-17022/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:26:10.228 1452-1452/? E/ExpandableNotifRow: onNotificationUpdated() NSSL is null..
18:26:10.499 736-17015/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
如您所见,我得到了3次(为什么是3次??)权限拒绝:...需要导出提供程序,或grantUriPersion()
。但是我的共享活动不仅设置了标志Intent.FLAG_GRANT_READ_URI_PERMISSION
,而且这在清单文件的提供程序部分中显示为android: grantUriPerments="true"
。
更奇怪的是,我可以在应用程序文件夹之外或子文件夹中共享sdcard中的文件(??!!!)。例如,我可以共享文件/store/58ED-1620/System Volume Information/WPSettings.dat
。看看logcat,即使有同样的3个错误,但文件被发送:
18:29:50.302 803-824/? E/BufferQueueProducer: [com.floritfoto.apps.ave/com.floritfoto.apps.xvf.FileChooser$_13168#1](id:323000009a8,api:0,p:-1,c:803) disconnect: not connected (req=1)
18:29:50.302 13168-14775/com.floritfoto.apps.ave W/libEGL: EGLNativeWindowType 0x708d001ec0 disconnect failed
18:29:50.325 736-758/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:29:50.328 736-758/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:29:50.331 1117-2951/? W/ActivityTaskManager: Tried to set launchTime (0) < mLastActivityLaunchTime (54810092)
18:29:50.333 1117-2951/? W/WindowManager: Execute app transition: mNextAppTransition=TRANSIT_ACTIVITY_OPEN, displayId: 0 Callers=com.android.server.wm.RootWindowContainer.executeAppTransitionForAllDisplay:2586 com.android.server.wm.ActivityStackSupervisor.reportResumedActivityLocked:2225 com.android.server.wm.ActivityRecord.completeResumeLocked:5646 com.android.server.wm.ActivityStack.minimalResumeActivityLocked:1212 com.android.server.wm.ActivityStackSupervisor.realStartActivityLocked:1135
18:29:50.340 5471-5471/? W/ChooserActivity: Ignoring intent's EXTRA_TITLE, deprecated in P. You may wish to set a preview title by using EXTRA_TITLE property of the wrapped EXTRA_INTENT.
18:29:50.342 1117-1379/? W/PkgPredictorService: background app without no launcher icon android for.uid: 1000 userId: 0
18:29:50.343 5471-5471/? E/ActivityThread: Failed to find provider info for com.samsung.android.app.sharestar.ShareStarProvider
18:29:50.387 1117-1135/? E/IntervalStats: Unable to parse usage stats package 1041
18:29:50.387 1117-1135/? E/IntervalStats: Unable to parse usage stats package 1520
18:29:50.387 1117-1135/? E/IntervalStats: Unable to parse usage stats package 1997
18:29:50.436 2498-3360/? W/NearbySharing: Ignore registering DIRECT_SHARE_SERVICE send surface, due to disabled scanning mediums. [CONTEXT service_id=194 ]
18:29:50.436 2498-3360/? W/NearbySharing: NearbySharingService call registerSendSurface returned nonzero status code for calling package com.google.android.gms: STATUS_DISABLED [CONTEXT service_id=194 ]
18:29:50.438 13168-14876/com.floritfoto.apps.ave E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/System%20Volume%20Information/WPSettings.dat from pid=5471, uid=1000 requires the provider be exported, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:841)
at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:758)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:684)
at android.content.ContentProvider$Transport.query(ContentProvider.java:239)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:106)
at android.os.Binder.execTransactInternal(Binder.java:1190)
at android.os.Binder.execTransact(Binder.java:1159)
18:29:50.438 5471-5471/? W/ChooserActivity: Could not load (content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/System%20Volume%20Information/WPSettings.dat) thumbnail/name for preview. If desired, consider using Intent#createChooser to launch the ChooserActivity, and set your Intent's clipData and flags in accordance with that method's documentation
18:29:50.466 1117-1145/? E/WindowManager: win=Window{19b8866 u0 com.floritfoto.apps.ave/com.floritfoto.apps.xvf.FileChooser EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.ActivityRecord.destroySurfaces:5183 com.android.server.wm.ActivityRecord.destroySurfaces:5164 com.android.server.wm.WindowState.onExitAnimationDone:5570 com.android.server.wm.WindowStateAnimator.onAnimationFinished:332 com.android.server.wm.WindowState.onAnimationFinished:6035 com.android.server.wm.-$$Lambda$dwJG8BAnLlvKNGuDY9U3-haNY4M.onAnimationFinished:2 com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$SurfaceAnimator:112
18:29:50.494 5471-5471/? W/View: requestLayout() improperly called by com.android.internal.widget.RecyclerView{9370694 VFED..... ......ID 0,0-1289,1011 #102047e android:id/resolver_list} during layout: running second layout pass
18:29:50.497 13168-14876/com.floritfoto.apps.ave E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/System%20Volume%20Information/WPSettings.dat from pid=5471, uid=1000 requires the provider be exported, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:841)
at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:758)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:684)
at android.content.ContentProvider$Transport.query(ContentProvider.java:239)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:106)
at android.os.Binder.execTransactInternal(Binder.java:1190)
at android.os.Binder.execTransact(Binder.java:1159)
18:29:50.498 5471-5471/? W/ChooserActivity: Could not load (content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/System%20Volume%20Information/WPSettings.dat) thumbnail/name for preview. If desired, consider using Intent#createChooser to launch the ChooserActivity, and set your Intent's clipData and flags in accordance with that method's documentation
18:29:50.553 736-758/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:29:50.553 736-758/? E/HYPER-HAL: [Request.cpp]acquire(): Request:: id : 648112, No Resource to set
18:29:50.553 736-758/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:29:50.554 803-1997/? E/BufferQueueProducer: [android/com.android.internal.app.ChooserActivity$_5471#0](id:323000009a9,api:0,p:-1,c:803) disconnect: not connected (req=1)
18:29:50.554 5471-6304/? W/libEGL: EGLNativeWindowType 0x708cf6ac50 disconnect failed
18:29:50.557 2339-2339/? E/pageboostd: Received HALT command code 2
18:29:50.569 13168-14876/com.floritfoto.apps.ave E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading androidx.core.content.FileProvider uri content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/System%20Volume%20Information/WPSettings.dat from pid=5471, uid=1000 requires the provider be exported, or grantUriPermission()
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:841)
at android.content.ContentProvider.semEnforceReadPermission(ContentProvider.java:758)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:684)
at android.content.ContentProvider$Transport.query(ContentProvider.java:239)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:106)
at android.os.Binder.execTransactInternal(Binder.java:1190)
at android.os.Binder.execTransact(Binder.java:1159)
18:29:50.569 5471-5471/? W/ChooserActivity: Could not load (content://com.floritfoto.apps.ave.provider/root/storage/58ED-1620/System%20Volume%20Information/WPSettings.dat) thumbnail/name for preview. If desired, consider using Intent#createChooser to launch the ChooserActivity, and set your Intent's clipData and flags in accordance with that method's documentation
18:29:50.703 5471-6332/? E/SharedPreferencesImpl: Couldn't create directory for SharedPreferences file /data/system/shared_prefs/com.android.internal.app.ChooserActivity.xml
18:29:50.725 727-1236/? E/Sensors: Sensor : Meta event
18:29:50.853 736-17345/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
18:29:50.919 1452-1452/? E/ExpandableNotifRow: onNotificationUpdated() NSSL is null..
18:29:51.329 736-17338/? E/HYPER-HAL: [HandlerSysfs.cpp]doResourceHandling(): Couldn't Open Sysfs - /sys/power/cstate_control
我看不出这两只Logcat有什么真正的不同!
我不知道为什么Android 11会出现这种情况。我做错了什么?这与作用域存储有关吗?我应该迁移到作用域存储吗?
这是文件共享方法:
public static void sharefile(Context context, String calledfrom, String filename) {
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sharingIntent.putExtra(Intent.EXTRA_STREAM, (new SearchOut()).getUriFromFile(context, calledfrom, new File(filename)));
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, FName.file(filename));
sharingIntent.setType((new FileChooser()).getMimeType(filename));
context.startActivity(Intent.createChooser(sharingIntent, filename));
}
编辑:在上面,getUriFromFile方法本质上是Android常用的方法
这是清单中我的提供商数据:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
这是我的provider_paths.xml
:
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="external_files" path="." />
<root-path name="root" path="." />
</paths>
在Android 11中,我们似乎无法通过FileProvider共享外部可移动微SD卡存储中应用程序自身文件中的文件:诀窍
<root-path name="root" path="." />
在提供程序路径中。xml文件不再适用于可移动存储中自己应用的文件夹(谢谢@blackapps!)。(然而,除了Android/data和Android/obb中的文件夹外,它仍然适用于可移动存储中的其他文件夹)。
因此,我的coward解决方法是将文件复制到主存储区ContextCompat中的应用程序缓存文件夹中进行共享。getExternalCacheDirs(上下文)[0],并从中共享文件。当应用程序关闭时,我会从缓存中删除此文件:/
我有一个经过验证的谷歌客户端,我想列出其他人公用文件夹中的文件(我认为共享或不共享的文件夹是不相关的,因为它是公用的) 这是我在NodeJS中的代码 注意:文档中没有“folderId”选项:https://developers.google.com/drive/api/v3/reference/files/list-只是一个drivid选项 虽然我将corpa设置为“drive”和drive I
我正在尝试传递一个位于我的应用程序的res/raw目录中的图像以及共享意图。 我遵循了FileProvider文档中描述的流程,下面是我的代码: Androidanifest.xml 我的活动中的代码: 由于无法访问我在其他应用程序中获取的文件,因此上述操作无效: java.io.FileNotFoundException:FILE_PATH:打开失败: EACCES(权限拒绝) 知道我做错了什么
我正在尝试共享RES/RAW文件夹中的音频文件。到目前为止我所做的是: 例如,当我选择在GMail上分享它时,它会说“无法附加空文件”之类的话。看来我没有得到正确的文件路径,所以我基本上没有共享任何东西。我做错了什么? 任何帮助都将不胜感激。
我的环境: SQL Server 2012 BI版 本地开发机器 共享网络文件夹和驱动器 null 我试过什么: WorkingDirectory:本地驱动器-解决方案有效 WorkingDirectory:共享文件夹-解决方案不会失败,但不会创建文件。我的帐户对该文件夹具有完全权限。 WorkingDirectory:映射驱动器使用Net USE,但未创建文件。 我已经部署了解决方案并运行了SQ
您可以使用共享文件夹 Microsoft 管理控制台 (MMC) 管理单元集中管理计算机上的文件共享。共享文件夹允许您创建文件共享和设置权限,查看和管理打开的文件以及连接到计算机上文件共享的用户。
本文向大家介绍服务器共享文件夹设置软件、文件共享服务器软件和共享文件夹加密工具的选择,包括了服务器共享文件夹设置软件、文件共享服务器软件和共享文件夹加密工具的选择的使用技巧和注意事项,需要的朋友参考一下 当前,很多企业都在局域网搭建了文件服务器,用于共享文件供局域网用户访问使用,并且很多共享文件都是单位积累的无形资产和商业机密,如何在允许员工访问服务器共享文件的同时还能保证服务器的安全呢?