【问题标题】:how to send media files via bluetooth in android如何在android中通过蓝牙发送媒体文件
【发布时间】:2015-04-14 01:43:54
【问题描述】:

我有一个要求。我需要构建一个应用程序,它使用蓝牙将歌曲、图像等媒体文件发送到另一台设备。我不知道如何做到这一点。任何人都可以从头开始帮助我大致了解如何完成这项工作。示例代码会很有帮助。

谢谢。

【问题讨论】:

    标签: android bluetooth media file-transfer


    【解决方案1】:

    我认为你应该读一遍这份文件。

    在这个例子中,他们从 SD 卡路径发送 PDF 文件,但我认为您也可以发送 像音频和视频一样的媒体文件。

    看到这个Bluetooth file transfer Android

    【讨论】:

      【解决方案2】:
      private void envio() {
          Intent intent = new Intent();
          intent.setAction(Intent.ACTION_SEND);
          intent.setType("text/plain");
          File archivo=new File(_path);
          intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(archivo) );
          ///////////////////pakage manager
          PackageManager pm = getPackageManager();
          List<ResolveInfo> appsList = pm.queryIntentActivities( intent, 1);
      
          if(appsList.size() > 0) {
              //Toast.makeText(this,"su telefono no cuenta con aplicacion de intercambio de datos",Toast.LENGTH_LONG).show();
          }
          //selleccionar la aplicacion de bluetooth
          String packageName = null;
          String className = null;
          boolean found = false;
          // BluetoothAdapter.checkBluetoothAddress("");
          for(ResolveInfo info: appsList){
      
            packageName = info.activityInfo.packageName;
            if( packageName.equals("com.android.bluetooth")){
               className = info.activityInfo.name;
               found = true;
               break;// found
            }
      
          }
          if(! found){
            Toast.makeText(this,"...",
                           Toast.LENGTH_SHORT).show();
            // exit
          }
      
          intent.setClassName(packageName, className);
          startActivity(intent);
      
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-11-15
        • 2016-05-07
        • 2016-05-08
        • 1970-01-01
        • 2012-02-14
        相关资源
        最近更新 更多