隨筆 - 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 建華 閱讀(656) 評論(0)  編輯  收藏 所屬分類: Android

          主站蜘蛛池模板: 鸡东县| 米脂县| 沽源县| 古田县| 修武县| 榆林市| 浦东新区| 晴隆县| 凤庆县| 东乌| 鄂托克旗| 来凤县| 平阴县| 松潘县| 上林县| 平原县| 平阳县| 青龙| 璧山县| 日照市| 浙江省| 曲周县| 洪湖市| 陈巴尔虎旗| 建始县| 婺源县| 中卫市| 蕲春县| 疏附县| 高淳县| 韶山市| 延庆县| 淮南市| 新津县| 陇川县| 阿合奇县| 东光县| 资溪县| 恩施市| 来安县| 砀山县|