求帮组,我的应用程序为啥mount不了sd卡?
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mText = (TextView) findViewById(R.id.textView);
b_mount = (Button)findViewById(R.id.button1);
b_umount = (Button)findViewById(R.id.button2);
if (mMountService == null)
{
IBinder service = ServiceManager.getService("mount");
if(service != null)
{
Log.i(TAG, "success to get service_mount");
mMountService = IMountService.Stub.asInterface(service);
}
else
{
Log.e(TAG, "Can't get mount service");
}
}
if (mStorageManager == null)
{
mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
if(mStorageManager == null){
Log.e(TAG, "Failed to get StorageManager");
}
Log.i(TAG, "success to get StorageManager");
mStorageManager.registerListener(mStorageListener);
}
/*
try
{
String state = mMountService.getVolumeState(MOUNTPOINT);
mText.setText("Media state " + state);
if (state.equals(Environment.MEDIA_MOUNTED))
mMountService.unmountVolume(MOUNTPOINT, true, true);
else if (state.equals(Environment.MEDIA_UNMOUNTED))
mMountService.mountVolume(MOUNTPOINT);
} catch (RemoteException e)
{
e.printStackTrace();
}
*/
b_mount.setOnClickListener(new OnClickListener(){
public void onClick(View v){
try{
Log.i(TAG, "mount button click");
mMountService.mountVolume(MOUNTPOINT);
}catch(RemoteException e)
{
Log.e(TAG, "mount click Exception");
e.printStackTrace();
}
}
});
b_umount.setOnClickListener(new OnClickListener(){
public void onClick(View v){
try{
Log.i(TAG, "unmount button click");
mMountService.unmountVolume(MOUNTPOINT, true, false);
}catch(RemoteException e)
{
Log.e(TAG, "unmount click Exception");
e.printStackTrace();
}
}
});
}
protected void onDestroy()
{
if(mStorageManager != null && mStorageListener != null)
mStorageManager.unregisterListener(mStorageListener);
super.onDestroy();
}
}
是用按钮实现的,奇怪为啥手机里setting里可以通过mount方法来挂载,为什么我的应用里操作不了呢??
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mText = (TextView) findViewById(R.id.textView);
b_mount = (Button)findViewById(R.id.button1);
b_umount = (Button)findViewById(R.id.button2);
if (mMountService == null)
{
IBinder service = ServiceManager.getService("mount");
if(service != null)
{
Log.i(TAG, "success to get service_mount");
mMountService = IMountService.Stub.asInterface(service);
}
else
{
Log.e(TAG, "Can't get mount service");
}
}
if (mStorageManager == null)
{
mStorageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
if(mStorageManager == null){
Log.e(TAG, "Failed to get StorageManager");
}
Log.i(TAG, "success to get StorageManager");
mStorageManager.registerListener(mStorageListener);
}
/*
try
{
String state = mMountService.getVolumeState(MOUNTPOINT);
mText.setText("Media state " + state);
if (state.equals(Environment.MEDIA_MOUNTED))
mMountService.unmountVolume(MOUNTPOINT, true, true);
else if (state.equals(Environment.MEDIA_UNMOUNTED))
mMountService.mountVolume(MOUNTPOINT);
} catch (RemoteException e)
{
e.printStackTrace();
}
*/
b_mount.setOnClickListener(new OnClickListener(){
public void onClick(View v){
try{
Log.i(TAG, "mount button click");
mMountService.mountVolume(MOUNTPOINT);
}catch(RemoteException e)
{
Log.e(TAG, "mount click Exception");
e.printStackTrace();
}
}
});
b_umount.setOnClickListener(new OnClickListener(){
public void onClick(View v){
try{
Log.i(TAG, "unmount button click");
mMountService.unmountVolume(MOUNTPOINT, true, false);
}catch(RemoteException e)
{
Log.e(TAG, "unmount click Exception");
e.printStackTrace();
}
}
});
}
protected void onDestroy()
{
if(mStorageManager != null && mStorageListener != null)
mStorageManager.unregisterListener(mStorageListener);
super.onDestroy();
}
}
是用按钮实现的,奇怪为啥手机里setting里可以通过mount方法来挂载,为什么我的应用里操作不了呢??
...全文
相关推荐
stm32f4通过spi用fatfs读写sd卡程序
**文件系统挂载**:使用`f_mount()`函数将SD卡挂载到FatFS上,指定逻辑驱动器号和文件系统结构。
Android 下通过反射调用加载/卸载(mount/unmount) 外置SD卡
在Android系统中,外置SD卡的加载与卸载通常由系统服务自动处理,但有时开发者可能需要在特定场景下进行手动操作,例如在应用程序中实现数据备份或系统优化功能。
基于CubeMX配置 FreeRTOS + SD + Fatfs 进行SD卡的读写操作
#### 六、读写操作实现一旦完成上述配置,就可以实现基本的SD卡读写功能了。具体步骤如下:1. **f_mount**:挂载文件系统。2. **f_open**:打开文件。3.
双重读取SD卡_Multi-Mount SD-Card_2.11已付费版
今天我们将深入探讨“双重读取SD卡”这一技术,以及名为“Multi-Mount SD-Card”的应用程序,版本号为2.11的付费版,以帮助用户更全面地理解这一功能及其优势。
android 获取外置SD卡路径
系统未提供获取外置SD卡的函数或方法,我们可以用Environment.getExternalStorageDirectory();来获取内置SD卡的路径,但是每款定制过的android 系统的外置S


