挂载/卸载SD卡,或对其进行模拟-Android [英] Mount/Unmount SDcard, or Simulate it - Android

查看:86
本文介绍了挂载/卸载SD卡,或对其进行模拟-Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android手机的默认媒体播放器会扫描sdcard中的歌曲文件,然后允许用户根据其扫描内容播放这些歌曲.

我制作的应用将其他歌曲文件写入sdcard,但是默认的媒体播放器看不到这些歌曲,因为它仅在以下两种情况下扫描歌曲文件:A:重新启动(电话打开).或B:安装电话的sdcard.

我的问题是我需要以编程方式卸载/装载sdcard,或模拟某些东西来欺骗音乐播放器,使他们认为这已经发生.

在Android中以编程方式安装sdcard 指出我需要使用设置"应用?

我不想使用其他应用程序. 我发现的所有其他文章都围绕模拟器进行.

解决方案

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

请注意,当广播此意图时,某些制造商的自定义操作系统版本无法正确扫描.我有一个motoblur设备,必须使用其他设备才能工作.不要确切地记得那是什么.

Edit: The default media player for Android phones scans the sdcard for song files and then allows the user to play these songs based on what it has scanned.

My app that I have made writes additional song files to the sdcard, but the default media player does not see these songs because it only scans for song files when it is either A: Rebooted (phone turns on). or B: when the phone's sdcard is mounted.

My problem is that I need to either programatically unmount/mount the sdcard, or simulate something that tricks the music player into thinking this has happened.

Mount sdcard programmitically in android states that I need to use a Settings app?

I do not wish to use another application. All other articles I have found revolve around the Emulator.

解决方案

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

Note that some manufacturers custom OS builds do not scan properly when this intent is broadcast. I had a motoblur device that I had to use something else in order to get working. Don't recall exactly what it was though.

这篇关于挂载/卸载SD卡,或对其进行模拟-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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