如何在 Android 上以编程方式安全地移除 SD 卡 [英] How to safely remove SD card programmatically on Android

查看:21
本文介绍了如何在 Android 上以编程方式安全地移除 SD 卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让用户在我的程序中安全地移除 SD 卡,但 Android 2.2 公共 API 似乎没有提供这样做的方法.有谁知道这样做的正确方法是什么?

I want to let the user safely remove the SD card in my program, but it seems the Android 2.2 public API does not provide a way to do this. Does anyone know what's a proper way to do it?

推荐答案

您需要将用户带到设备的内置设置.我认为这会奏效.

You need to take the user to the device's built-in Settings. I think this will work.

    Intent i = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS);
    startActivity(i);

卸载 SD 卡是其中一种操作,如果它不受用户的完全控制,可能会被恶意使用.如果它可以完全在软件中完成(无需用户干预),那么代码可能会干扰设备上运行的其他应用.

Unmounting the SD card is one of those actions which could be used maliciously if it wasn't under full user control. If it could be done purely in software (without user intervention) then code could disrupt other apps running on the device.

这篇关于如何在 Android 上以编程方式安全地移除 SD 卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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