Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid bluetooth print stopped working on 4.1
    text
    copied!<p>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:</p> <blockquote> <p>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()</p> </blockquote> <p>The problem is that we are declaring that permission, so this error makes no sense to us. Here is the line from our manifest</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.turner.itstrategy.LumenboxClient" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="11" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_BLUETOOTH_SHARE"/&gt; &lt;uses-permission android:name="android.permission.BLUETOOTH"/&gt; &lt;uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; &lt;uses-permission android:name="android.permission.VIBRATE" /&gt; (stuff removed) &lt;/manifest&gt; </code></pre> <p>Here is the code we are using to print. This code has been taken from examples on stackoverflow and elsewhere.</p> <pre><code>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); </code></pre> <p>Right now we are dead in the water.. any advice appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload