android sd卡异常拔出,Android上拔出sd卡导致flash上媒体也消失问题解决方法

机器内部有一部分flash供客户使用,同时机器支持sd卡。当插入sd卡时候flash内部和sd卡内部的多媒体都可以被播放器识别,一旦拔掉sd卡,则flash内的媒体对播放器也不见了。

解决方法:

修改frameworks/base/services/java/com/Android/server/MountService.java文件的函数:notifyMediaBadRemoval如下,红色为添加。

mContext.sendBroadcast(intent);

intent = new Intent(Intent.ACTION_MEDIA_REMOVED,

Uri.parse("file://" + path));

mContext.sendBroadcast(intent);

//添加下面几行

intent = new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://" + "flash"));

intent.putExtra("read-only", false);

mContext.sendBroadcast(intent);

}

同时也修改notifyMediaUnmounted(),在最后也加入上面几行

Intent intent = new Intent(Intent.ACTION_MEDIA_UNMOUNTED,

Uri.parse("file://" + path));

mContext.sendBroadcast(intent);

//添加开始

intent = new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://" + "flash"));

intent.putExtra("read-only", false);

mContext.sendBroadcast(intent);

//添加结束0b1331709591d260c1c78e86d0c51c18.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值