系統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);