我正在开发一个应用程序,它显示应用程序中whatsapp状态的列表。现在我的问题是,在限定了作用域的存储之后,我们无法访问特定的路径,那么现在该怎么办呢?还是所有whatsapp状态保护程序应用程序将来都不能工作?现在,我可以像这样访问statuses文件夹。
String whatsappStatus = (Environment.getExternalStorageDirectory().getAbsolutePath() + "/WhatsApp/Media/.Statuses");但它并不适用于我使用的course.If的android 11。
All files
要访问手机上的所有文件,google play不允许使用,除非这是最后一个解决方案,这不是这里的情况。
未来whatsapp是否有希望直接在公共场合存储身份,或者允许直接访问该特定信息?
发布于 2022-07-11 08:16:42
private void checkWhatsAppPermission(){
// Choose a directory using the system's file picker.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
// Optionally, specify a URI for the directory that should be opened in
// the system file picker when it loads.
Uri wa_status_uri = Uri.parse("content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia/document/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsApp%2FMedia%2F.Statuses");
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, wa_status_uri);
startActivityForResult(intent, 10001);
}您可以在这里检查一个工作示例。https://play.google.com/store/apps/details?id=com.larntech.whatsappstatussaver
发布于 2022-07-14 06:57:59
您应该使用运行时权限,即存储访问框架权限读取文档。
使用系统的文件选择器选择一个目录。
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
Uri wa_status_uri = Uri.parse("content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia/document/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsApp%2FMedia%2F.Statuses");
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, wa_status_uri);
startActivityForResult(intent, 10001);发布于 2021-05-26 12:38:59
新路径
String whatsappStatus = (Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/media/com.whatsapp/WhatsApp/Media/.Statuses");并给出一个像这样的条件
if (android.os.Build.VERSION.SDK_INT < 30) {
String whatsappStatus = (Environment.getExternalStorageDirectory().getAbsolutePath() + "/WhatsApp/Media/.Statuses");
}else {
String whatsappStatus = (Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/media/com.whatsapp/WhatsApp/Media/.Statuses");
}https://stackoverflow.com/questions/67424951
复制相似问题