实际上,我正在开发一个免费的应用程序,当按下某个按钮时,它需要通过蓝牙共享,并且我使用了以下代码(我试图从sd卡获取文件):
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
// Device does not support Bluetooth
}
if (!mBluetoothAdapter.isEnabled()) {
Toast.makeText(getApplicationContext(), "Bluetooth is turned off, please enable it to proceed!", Toast.LENGTH_LONG).show();
}
else {
File sourceFile = findFile(Environment.getExternalStorageDirectory(),"E-charge.apk");
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("application/vnd.android.package-archive");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(sourceFile) );
startActivity(intent);
}下面是与这个按钮所在的活动相关的清单:
<activity
android:name=".main.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
<data android:host="*"/>
<data android:pathPattern="*.*\\.apk" />
</intent-filter>
</activity>然而,当我按下按钮(在Android2.3.5中)时,我可以选择只通过电子邮件发送,而不是蓝牙,所以我可以请求您的帮助吗?
此外,我增加了蓝牙人的权限,所以不是这样的!
发布于 2014-05-02 11:21:30
您只需更改以下一行:
intent.setType("application/vnd.android.package-archive");
至
intent.setType("application/zip");https://stackoverflow.com/questions/22795232
复制相似问题