在Google Chrome ARC应用中访问ExternalStoragePublicDirectory [英] Accessing ExternalStoragePublicDirectory in Google Chrome ARC app

查看:126
本文介绍了在Google Chrome ARC应用中访问ExternalStoragePublicDirectory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序中有一项功能,可以将文件保存到ExternalStoragePublicDirectory.以下是我们正在使用的目录路径. Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

文件似乎已保存在目录中.但是我无法在Desktop或Chromebook中找到保存的文件.有人可以指出我正确的方向吗?

解决方案

在ARC下,正在读取您的外部存储文件并将其写入HTML5文件系统.在Chrome应用(包含您的应用)下,拥有自己的文件系统.

您可以使用一些实验性开发人员工具在Chrome(台式机或Chromebook)中查看此文件系统.您必须启用它们,然后重新启动浏览器.方法如下:

  • 在浏览器中访问"chrome://flags".
  • 搜索启用开发人员工具实验",然后单击启用"链接.
  • 应该已经出现了重新启动浏览器的提示.继续并单击它以重新启动浏览器.
  • 继续并启动您的应用程序.它需要运行,以便您可以浏览文件系统.
  • 接下来,在浏览器中访问"chrome://inspect/#apps"页面,然后在列表中找到您的应用.单击检查"链接以打开检查器窗口.
  • 点击窗口右上方的齿轮图标.
  • 单击弹出窗口左侧列出的实验"标签.仅在完全启用实验功能的情况下,此选项才可见.
  • 单击文件系统检查"复选框以启用文件系统查看器.
  • 通过关闭选项页面(左上角带有"x")来完成操作.

现在您可以查看应用程序的文件系统.

  • 在应用程序的检查器窗口中,单击顶部的资源"标签.
  • 您应该看到左侧列表中出现了"FileSystem"选项.单击以将其展开.
  • 点击持久-chrome扩展名:"子面板.
  • 您应该能够通过展开显示的视图来导航到下载目录.我相信要下载的文件是"/storage/sdcard/Download".

选择目录将在目录中的所有文件上显示基本元数据.如果支持,选择文件可能会显示它.否则,您可能会收到二进制文件"消息.

如果您想实际操作其他数据,则需要使用Android adb命令/shell与浏览器连接,并且应该能够"adb提取"文件.请参见 https://developer.chrome.com/apps/getstarted_arc#bestpractices 进行操作. >

您还可以将{"enableExternalDirectory": true}添加到应用程序的元数据中.启用此选项意味着ARC将提示您输入要用于外部目录的目录,并且您可以选择系统上要使用的真实目录.但是,如果在启用此功能之前已经下载了文件,则必须再次下载.

We have a feature in our app which can save file to ExternalStoragePublicDirectory. Below is the directory path we are using. Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

It looks like file is getting saved in the directory. But I cant locate the saved file in Desktop or Chromebook. Can anybody please point me to right direction?

解决方案

Under ARC, your external storage files are being read and written to the HTML5 filesystem. Under Chrome app (yours included) gets its own filesystem.

You can view this filesystem with Chrome (desktop or Chromebook) using some experimental developer tools. You have to enable them and then restart the browser. Here is how:

  • Visit "chrome://flags" in your browser.
  • Search for "Enable Developer Tools experiments", and click the "Enable" link.
  • A prompt to restart your browser should have appeared. Go ahead and click it to restart your browser.
  • Go ahead and launch your app. It needs to be running so that you can browse the filesystem.
  • Next visit the "chrome://inspect/#apps" page in your browser, and find your app in the list. Click the "inspect" link to bring up the inspector window.
  • Click the gear icon in the upper right of the window.
  • Click the "Experiments" tab listed on the left side of the popup. This is only visible if you enabled the experimental features at all.
  • Click the "Filesystem Inspection" checkbox to enable the filesystem viewer.
  • Finish up by closing the options page with the "x" at the top left.

Now you can view your app's filesystem.

  • From the inspector window for your app, click the "Resources" tab along the top.
  • You should see a "FileSystem" option appear in the list on the left side. Click it to expand it.
  • Click the "persistent -chrome extension:" subpanel.
  • You should be able to then navigate to the download directory by expanding the view that appears. I believe for downloads you want "/storage/sdcard/Download".

Selecting the directory will display basic metadata on all the files in the directory. Selecting the file might display it if it is supported. Or you might just get a "Binary File" message if not.

If you want to actually manipulate the data beyond that, you will need to connect with the browser with the Android adb command/shell, and you should be able to "adb pull" the file. See https://developer.chrome.com/apps/getstarted_arc#bestpractices to get going on that.

You can also add {"enableExternalDirectory": true} to your application's metadata. Enabling this option means that ARC will prompt you for the directory to use for for the external directory, and you can pick a real directory on your system to use. But if you already download a file prior to enabling this feature, you will have to download it again.

这篇关于在Google Chrome ARC应用中访问ExternalStoragePublicDirectory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆