android蓝牙4.1,Android bluetooth print stopped working on 4.1

We have an application that prints images to a bluetooth printer. This application has been working fine on Android 4.0 ICS but when we upgraded one of them to Android 4.1 jelly bean, printing stopped working with this in logcat:

W/System.err(19319): java.lang.SecurityException: Permission Denial:

writing com.android.bluetooth.opp.BluetoothOppProvider uri

content://com.android.bluetooth.opp/btopp from pid=19319, uid=10106

requires android.permission.ACCESS_BLUETOOTH_SHARE, or

grantUriPermission()

The problem is that we are declaring that permission, so this error makes no sense to us. Here is the line from our manifest

package="com.turner.itstrategy.LumenboxClient"

android:versionCode="1"

android:versionName="1.0" >

(stuff removed)

Here is the code we are using to print. This code has been taken from examples on stackoverflow and elsewhere.

ContentValues values = new ContentValues();

String path = Environment.getExternalStorageDirectory().toString();

File imageFile = new File(path, "CurrentLumenboxPrint.jpg");

//build the message to send on BT

values.put(BluetoothShare.URI, Uri.fromFile(imageFile).toString());

values.put(BluetoothShare.MIMETYPE, "image/jpeg");

values.put(BluetoothShare.DESTINATION, device.getAddress());

values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND);

Long ts = System.currentTimeMillis();

values.put(BluetoothShare.TIMESTAMP, ts);

// Here is where the exception happens

final Uri contentUri = getApplicationContext().getContentResolver().insert(BluetoothShare.CONTENT_URI, values);

Right now we are dead in the water.. any advice appreciated.

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值