調用原生系統的文件分享中的藍牙分享功能
//調用android分享窗口
Intent intent2 = new Intent(Intent.ACTION_SEND);
intent2.setType("*/*");
intent2.setPackage("com.android.bluetooth");
intent2.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath() + "//" + "盤點導入//" + fileName)));//path爲文件的路徑
intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//7.0以上可能會報錯 java.lang.SecurityException: Permission Denial
//使用這一段即可
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
builder.detectFileUriExposure();
Intent chooser = Intent.createChooser(intent2, "Share app");
chooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(chooser, "分享"));