隨筆 - 33, 文章 - 0, 評論 - 12, 引用 - 0
          數據加載中……

          藍牙發送文件

          系統4.0.3以后的
                File file=new File("");
           Uri uri1 = Uri.fromFile(file);
           Intent intent = new Intent();    
          intent.setAction(Intent.ACTION_SEND);   
           //intent.setType("audio/*"); 
            intent.setType("application/octet-stream");
          ComponentName comp=new ComponentName("com.mediatek.bluetooth","com.mediatek.bluetooth.BluetoothShareGatewayActivity");
          intent.setComponent(comp);
           intent.putExtra(Intent.EXTRA_STREAM, uri1);
          startActivity(intent);
          系統4.0.3以前的
          Intent intent = new Intent();
          intent.setAction(Intent.ACTION_SEND);
          //這個類型函數是自己工具類的方法,你可以自己設置文件類型,例如圖片文件:image/*  
            //不想寫類型直接*/*也是可以的
          intent.setType("audio/*");
          //這里setClassName就是指定藍牙,不寫這句就彈出選擇用什么發送
            //有藍牙啊,gmail啊,彩信之類的
          intent.setClassName("com.android.bluetooth" , "com.android.bluetooth.opp.BluetoothOppLauncherActivity");
          intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("")));
          startActivity(intent);


            ArrayList<Uri> uris = new ArrayList<Uri>();
             uris.add(Uri.fromFile(new File("/sdcard/111.txt")));
             uris.add(Uri.fromFile(new File("/sdcard/222.txt")));
             
                         Intent intent = new Intent();
          intent.setAction(Intent.ACTION_SEND_MULTIPLE);
          intent.setType("video/*");
          intent.setClassName("com.android.bluetooth" , "com.android.bluetooth.opp.BluetoothOppLauncherActivity");
          //intent.setClassName("com.mediatek.bluetooth","com.mediatek.bluetooth.BluetoothShareGatewayActivity");
          //intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/111.txt")) );
          //intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/222.txt")));
          intent.putExtra(Intent.EXTRA_STREAM, uris);
          startActivity(intent);

          posted on 2013-02-20 08:45 建華 閱讀(655) 評論(0)  編輯  收藏 所屬分類: Android

          主站蜘蛛池模板: 林州市| 同江市| 体育| 闻喜县| 日照市| 巴林左旗| 泸溪县| 大同县| 富宁县| 克山县| 恩施市| 湟源县| 沧源| 灯塔市| 阳朔县| 师宗县| 桑日县| 称多县| 芮城县| 深水埗区| 太仆寺旗| 连平县| 乐山市| 花垣县| 讷河市| 泽库县| 罗山县| 正蓝旗| 水富县| 五河县| 新龙县| 迁安市| 北流市| 昔阳县| 宾川县| 广灵县| 夏津县| 玉树县| 阿尔山市| 洪江市| 天峻县|