Elija un archivo de la tarjeta SD con Intent

¿Android tiene alguna manera de navegar y recoger cualquier archivo de la tarjeta SD con intentos? Algo como

String uri = (Environment.getExternalStorageDirectory()).getAbsolutePath(); Intent i = new Intent(Intent.ACTION_PICK,Uri.parse(uri)); 

Estoy tratando de enviar un archivo a otros dispositivos mediante Bluetooth. Puedo enviar si doy la trayectoria completa del nombre de archivo en mi código. Quiero que mis usuarios escogen el archivo que se debe enviar.

Puede utilizar el siguiente código

 Intent mediaIntent = new Intent(Intent.ACTION_GET_CONTENT); mediaIntent.setType("video/*"); //set mime type as per requirement startActivityForResult(mediaIntent,REQUESTCODE_PICK_VIDEO); 

Entonces usted puede conseguir la trayectoria en onActivityResult

 @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUESTCODE_PICK_VIDEO && resultCode == Activity.RESULT_OK) { Uri videoUri = data.getData(); Log.d("", "Video URI= " + videoUri); } } 

Para la navegación general utilice esto (por ejemplo, archivo de música):

 Intent intent = new Intent(); intent.setType("*/*"); if (Build.VERSION.SDK_INT < 19) { intent.setAction(Intent.ACTION_GET_CONTENT); intent = Intent.createChooser(intent, "Select file"); } else { intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); String[] mimetypes = { "audio/*", "video/*" }; intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes); } startActivityForResult(intent, Constants.REQUEST_BROWSE); 

Y recibe los datos aquí:

 @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == Constants.REQUEST_BROWSE && resultCode == Activity.RESULT_OK && data != null) { Uri uri = data.getData(); if (uri != null) { // TODO: handle your case } } } 
  • Error al leer datos de InputStream en Bluetooth en Android
  • SetNeedBle de SettingsApi no funciona en API23
  • ¿Cómo detectar el cambio de estado Bluetooth con un receptor de difusión?
  • Android Bluejacking Bluetooth posible?
  • Implementar un tiempo de espera en BluetoothSocket inputstream.read () en Android
  • Android: impresión Bluetooth
  • El dispositivo Android BLE se desconecta después de poco tiempo, el código de error 8
  • El bluetooth androide no puede conectarse
  • Voz al texto Convertir por auriculares Bluetooth
  • Android BluetoothSocket write falla en 4.2.2
  • Conexiones simultáneas de Bluetooth
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.