Android中有关于获取外挂设备的路径以及基本信息
来源:互联网 发布:淘宝卖家怎么加入一淘 编辑:程序博客网 时间:2024/06/16 18:05
/** * 获取所有存储卡挂载路径 * @return */ /* public static List getMountPathList() { List pathList = new ArrayList(); final String cmd = "cat /proc/mounts"; Runtime run = Runtime.getRuntime();//取得当前JVM的运行时环境 try { Process p = run.exec(cmd);//执行命令 BufferedInputStream inputStream = new BufferedInputStream(p.getInputStream()); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = bufferedReader.readLine()) != null) { // 获得命令执行后在控制台的输出信息 //Log.d( "MainActivity", line ); //输出信息内容: /data/media /storage/emulated/0 sdcardfs rw,nosuid,nodev,relatime,uid=1023,gid=1023 0 0 String[] temp = TextUtils.split(line," "); //分析内容可看出第二个空格后面是路径 String result = temp[1]; File file = new File( result ); //类型为目录、可读、可写,就算是一条挂载路径 if (file.isDirectory() && file.canRead() && file.canWrite()) { //if ( file.isDirectory() && file.canRead() ) { Log.d( "MainActivity", "add -->" + file.getAbsolutePath()); pathList.add(result); } // 检查命令是否执行失败 if (p.waitFor() != 0 && p.exitValue() == 1) { // p.exitValue()==0表示正常结束,1:非正常结束 Log.e("MainActivity", "命令执行失败!"); } } bufferedReader.close(); inputStream.close(); } catch (Exception e) { Log.e( "MainActivity", e.toString() ); //命令执行异常,就添加默认的路径 pathList.add(Environment.getExternalStorageDirectory().getAbsolutePath()); } return pathList; } */ /* public String getUsbStorageName() { String name = ""; /* try { //获得外接USB输入设备的信息 Process p = Runtime.getRuntime().exec("cat /proc/bus/input/devices"); BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line = null; while( (line = in.readLine()) != null ){ String deviceInfo = line.trim(); Log.d("MainActivity", deviceInfo); } } catch (Exception e) { e.printStackTrace(); } */ /* //获得各盘符路径 DeviceMountInfo dev = DeviceMountInfo.getInstance(); DeviceMountInfo.DevInfo info; info = dev.getInternalInfo(); Log.d("MainActivity", info.getLabel() + ":" + info.getMount_point()); Environment.getExternalStorageDirectory() 这两个要是不一样咋办 info = dev.getExternalInfo(); Log.d("MainActivity", info.getLabel() + ":" + info.getMount_point()); info = dev.getUSBInfo(); Log.d("MainActivity", info.getLabel() + ":" + info.getMount_point()); *//* UsbManager manager = (UsbManager)getSystemService(Context.USB_SERVICE); HashMap deviceList = manager.getDeviceList(); if (deviceList.size() == 0) { return name; } Iterator deviceIterator = deviceList.values().iterator(); UsbDevice device; while( deviceIterator.hasNext() ) { device = deviceIterator.next(); Log.d(TAG, "Name: " + device.getDeviceName()+"\n" + "VID:" + device.getVendorId() + " PID:" + device.getProductId() + " PN:" + device.getProductName() + " DID:" + device.getDeviceId() + " MN:" + device.getManufacturerName() + " SN:" + device.getSerialNumber() ); //data.add("Name: " + device.getDeviceName()+"\n" // + "VID: " + device.getVendorId() // + "PID: " + device.getProductId()); } return name; } */
0 0
- Android中有关于获取外挂设备的路径以及基本信息
- 获取Android设备基本信息
- Android获取设备或应用基本信息
- Android获取手机的基本信息
- ios获取设备基本信息
- Android中获取手机联系人的基本信息的实现
- Android获取内置、外置以及OTG等方式挂载的存储设备路径
- Android:相册中获取图片以及路径
- Android App 获取设备基本信息(yoos、懂你)
- php有关于路径的问题分析
- Android 获取手机的一些基本信息
- Android 获取手机的一些基本信息类
- iOS中有关沙盒的一些知识的介绍(获取沙盒路径以及沙盒文件操作等)
- iOS中有关沙盒的一些知识的介绍(获取沙盒路径以及沙盒文件操作等)
- 在Android学习中有关于广播注册的问题
- 苹果助手开发随笔系列:2、设备连接以及获取设备基本信息
- Android获取系统基本信息
- 获取android手机基本信息
- 直方图
- spring整合redis的错误
- opengles绘制天空穹
- Python print函数用法,print 格式化输出
- 模仿小米安全中心的进度效果
- Android中有关于获取外挂设备的路径以及基本信息
- oracle-同义词
- 线程机制:并发函数的使用
- 使用EditText+ListView并结合TextWatcher实现输入关键字筛选数据
- mvc 分离外部js文件以及调用方法
- C# Unity依赖注入
- Linux下高并发socket最大连接数所受的各种限制
- Retrofit2.0 GsonResponseBodyConverter类修改,解决网络访问默认返回空对象进入onFailure的问题
- Android中退出多个Activity的两个方法