Bluetooth Opp发送文件
来源:互联网 发布:怎样自学软件测试 编辑:程序博客网 时间:2024/04/30 04:05
Intent intent = new Intent(Intent.ACTION_SEND);intent.setClassName("com.android.bluetooth","com.android.bluetooth.opp.BluetoothOppLauncherActivity"); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Ludimate.sisx")); // imageUri set previouslyintent.setType("**");values.put("destination", mDevice.getAddress());values.put("direction", 0);values.put("VISIBILITY", 1);values.put("is_push", 1);contxt.getContentResolver().insert(CONTENT_URI, values); Intent intent = new Intent( "android.bluetooth.devicepicker.action.DEVICE_SELECTED"); intent.setClassName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppReceiver"); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice); sendBroadcast(intent);// Intent intent = new Intent(Intent.ACTION_SEND);// intent.setClassName("com.android.bluetooth","com.android.bluetooth.opp.BluetoothOppLauncherActivity");// intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/Ludimate.sisx")); // // imageUri set previously// intent.setType("*/*");// startActivity(intent);
我们在实现共享功能的时候,通常使用的是Intent intent = new Intent(Intent.ACTION_SEND)这样的代码,这种情况会弹出一个共享功能的选择界面,比如通过微博、蓝牙、邮件等等很多途径,现在我要实现的是跳过这个选择界面,直接选用蓝牙途径进行共享文件,代码如下
/** 蓝牙功能包名 /
private final String mBluetoothPackageName = "com.android.bluetooth";/* 蓝牙功能操作类名 */private final String mBluetoothClassName = "com.android.bluetooth.opp.BluetoothOppLauncherActivity";mSelfApkPath = getSelfAPKPath(mSelfApkPackage);File file = new File(mSelfApkPath);Intent intent = new Intent();try {intent.setAction(android.content.Intent.ACTION_SEND);intent.setType("*/*");// 以下此行代码功能为直接指向系统蓝牙搜索设备界面,去掉即跳转至客户端选择分享途径intent.setClassName(mBluetoothPackageName, mBluetoothClassName);intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));startActivity(intent);} catch (Exception e) {Toast.makeText(this, "该设备可能不支持蓝牙功能...",Toast.LENGTH_SHORT).show();}
在实现过程中,手中的测试机器在执行到startActivity(intent)时并不会抛异常,而后面无意中却发现有的手机在这句程序居然抛出了异常,异常信息如下:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.bluetooth/com.android.bluetooth.opp.BluetoothOppLauncherActivity}; have you declared this activity in your AndroidManifest.xml?
0 0
- Bluetooth Opp发送文件
- 有关Android Bluetooth - OBEX OPP文件传送
- 有关Android Bluetooth - OBEX OPP文件传送
- 有关Android Bluetooth - OBEX OPP文件传送
- Bluetooth OPP Profile
- android 蓝牙 bluetooth OPP文件传输
- Android Bluetooth opp package 学习笔记
- android -- 蓝牙 bluetooth (四)OPP文件传输
- android -- 蓝牙 bluetooth (四)OPP文件传输
- android4.4 bluetooth OPP 之BluetoothOppSendFileInfo
- android -- 蓝牙 bluetooth (四)OPP文件传输
- 兔子-蓝牙 bluetooth (四)OPP文件传输
- android -- 蓝牙 bluetooth (四)OPP文件传输
- android -- 蓝牙 bluetooth (四)OPP文件传输
- android -- 蓝牙 bluetooth (四)OPP文件传输
- android -- 蓝牙 bluetooth (四)OPP文件传输
- C# BlueTooth 连接 接收 发送文件
- android 4.2 bluetooth OPP 蓝牙启动,扫描,使能
- django 词典 json
- c语言 malloc(0)的问题
- POJ 1253 SPF(tarjan算法求割点)
- 神과 사람의 相祐 (韓長經 易學原理總論)
- GIS开源类库
- Bluetooth Opp发送文件
- HTTP Cache
- 上传文件代码的实现
- Lambda 表达式编写递归
- 在公司传播流言以及负面能量给你带来厄运
- 音频设备的3种硬件接口--PCM,IIS和AC97 .
- java 23种设计模式
- LUA 类型转换
- c# 一些小函数