android挂载卸载sd卡

发布于 2024-11-28 09:27:14 字数 195 浏览 3 评论 0原文

我正在开发一个扫描 SD 卡的应用程序。此时,我正在使用eclipse的模拟器来测试我的android应用程序。我创建了一个虚拟 SD 卡用于在 Eclipse 上进行测试。

我想知道是否有任何方法可以卸载然后将 SD 卡安装在模拟器(Eclipse)上,以便我可以测试我的应用程序,当卸载 SD 卡时,它应该生成一条消息等

。有人帮助我吗..

I am working on an application that scans the sd card. At this time, I am using the emulator of eclipse to test my android application. I have created a virtual sd-card for testing purposes on eclipse.

I want to know if there is any way of un-mounting and then mounting the sd card on the emulator (eclipse) so that I can test my application that when the sd-card is unmounted, it should generate a message etc..

Can anyone help me here..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

指尖微凉心微凉 2024-12-05 09:27:15

可以在没有外部存储的情况下启动设备,这使您可以测试当您没有获得Environment.MEDIA_MOUNTED状态时会发生什么。

只需使用现有 SD 卡 .iso 文件创建 AVD。然后,重命名该文件。当您加载此 AVD 时,它会正常工作,但不会加载外部存储。这允许您测试未安装外部媒体时的逻辑。

我创建了一个单独的 AVD 来测试无外部存储场景,但如果您想在同一个测试上运行这两个测试,您可以重命名 .iso 文件并重新启动模拟器。

我确实尝试了上面的 umount 方法,虽然它很有用(正如 Torp 提到的,这是一个更严格的测试),但系统仍然认为 SD 卡已安装,并且我的备用逻辑未运行。

It is possible to boot the device without the external storage, which allows you to test what happens when you do not get the Environment.MEDIA_MOUNTED state.

Just create an AVD with an existing SD card .iso file. Then, rename the file. When you load this AVD, it will work just fine but it won't have the external storage loaded. This allows you to test your logic for when the external media isn't mounted.

I created a separate AVD for testing the no-external-storage scenario, but you could rename the .iso file and restart the emulator if you want to run both tests on the same one.

I did try the umount method above, and while it's useful (as Torp mentions, it's a harsher test), the system still thinks the SD card is mounted and my alternate logic isn't run.

天涯离梦残月幽梦 2024-12-05 09:27:15

嗯,我刚刚启动了一个模拟器,使用 adb shell 获得了 root shell,并开始卸载东西。看起来效果很好。
必须在 2.3.3 虚拟机上执行 umount /mnt/sdcard/.android_secure,然后再执行 umount /mnt/sdcard,但它似乎有效。在卸载之前使用 mount 检查虚拟机上的内容。
当然,这是一个比从 Android UI 卸载更“严厉”的解决方案 - 有点模拟用户删除 SD 卡而不先卸载它 - 但它可能有助于您的测试。

Hmm i just started an emulator, got a root shell with adb shell and started unmounting things. It seemed to work just fine.
Had to do umount /mnt/sdcard/.android_secure and then umount /mnt/sdcard on a 2.3.3 VM but it seemed to work. Check what's on your VM with mount before umounting.
Of course this is a much "harsher" solution than umounting from the Android UI - kind of simulates an user that removes the sd card without umounting it first - but it may help with your testing.

东风软 2024-12-05 09:27:15

模拟器运行时无法安装/卸载虚拟 SD 卡,如下所述 (重新)在Android模拟器上安装SD卡

如果您想测试您的应用程序,我建议您找到一个真实的设备。

You can't mount/unmound virtual SD card while the emulator is running as explained here (re)mounting the SD card on android emulator

If you want to test your app, I suggest you to find a real device.

农村范ル 2024-12-05 09:27:15

抱歉我的无知,但为什么你不能进入 Android 设置菜单,然后选择存储并卸载 SD 卡?您可以用同样的方式将其安装回去。它在名为使用 Eclipse 的模拟器下工作。我的版本ADT adt-bundle-windows-x86_64-20140702

Sorry for my ignorance but why can't you go to Android Setting menu then select Storage and unmount SD card? You can mount it back in same way. It works under emulator called using Eclipse. My version ADT adt-bundle-windows-x86_64-20140702

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文