private BroadcastReceiver usbReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d("+++++++++++","action="+intent.getAction());
//Toast.makeText(ThunderGuideActivity.this, "action-----"+intent.getAction(), Toast.LENGTH_LONG).show();
if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
//usbtextview.setTextColor(Color.GREEN);
//usbtextview.setText(R.string.diskOk);
//硬盘挂载好了
try {
JsonUtil.RequestURL(url);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if (action.equals(Intent.ACTION_MEDIA_REMOVED)
||action.equals(Intent.ACTION_MEDIA_UNMOUNTED)
||action.equals(Intent.ACTION_MEDIA_EJECT) ) {
Log.v("chenguo", "============usbtest=============intent.getPackage()= "+ intent.getPackage()+" intent.getData()= " + intent.getData());
String devicePath = intent.getDataString().toLowerCase().substring(7);//卸载u盘对应路径
Log.v("chenguo", "============usbtest=============devicePath()= "+ devicePath +" intent.getDataString().toLowerCase()= " + intent.getDataString().toLowerCase()+" intent.getDataString()"+intent.getDataString());
}
}
};