Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Android 6.0 (API 23) #17

Open
Astrovic opened this issue May 2, 2016 · 12 comments
Open

Error on Android 6.0 (API 23) #17

Astrovic opened this issue May 2, 2016 · 12 comments

Comments

@Astrovic
Copy link

Astrovic commented May 2, 2016

I'm trying module on my nexus 5x, but I get this error message in the log:

[WARN] :   Binder: Caught a RuntimeException from the binder stub implementation.
[WARN] :   Binder: java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results
[WARN] :   Binder:  at android.os.Parcel.readException(Parcel.java:1620)
[WARN] :   Binder:  at android.os.Parcel.readException(Parcel.java:1573)
[WARN] :   Binder:  at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:772)
[WARN] :   Binder:  at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onClientRegistered(BluetoothLeScanner.java:324)
[WARN] :   Binder:  at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:56)
[WARN] :   Binder:  at android.os.Binder.execTransact(Binder.java:453)
@rwuttke
Copy link

rwuttke commented May 2, 2016

There are several fixes for this problem.

First need to get a newer version of Radius.jar from Radius Networks and update the code to support it as the namespaces have changed.

http://developer.radiusnetworks.com/2016/04/12/beacon-apps-on-android-6-update.html

Then you will need to add code to your application to request the Permissions for LOCATION.

Here is the catch, your app will need a custom version of 5.2.0.GA SDK, because it doesn't have the Permissions for Android baked in.

For more information, please look here

http://gitt.io/component/ti.permissions

http://stackoverflow.com/questions/35890378/how-to-request-run-time-recording-permission-on-android-6-0

@rwuttke
Copy link

rwuttke commented May 2, 2016

I have created a new version locally of the Library to support this, may have to actually use GitHub and create a Pull Request.

@Astrovic
Copy link
Author

Astrovic commented May 2, 2016

OK, thank you, I solved asking localization allowed after starting the app :)
Another question. Is there a way to check if the bluetooth status is on or off? Because I noticed that if when I start module the bluetooth is not enabled (status off), if I enable subsequently the bluetooth, module don't works. So the bluetooth must already be running before you start tracking beacons.
Thanks :)

@rwuttke
Copy link

rwuttke commented May 2, 2016

The is a checkAvailability which basically says "Is BT on or existing".

You can use this function.

One thing you could do is setup an interval and call this.

Something like this at it's core. Obviously you will need to track that you have shown this otherwise each time the even fires it will show it if the user has not enabled bluetooth and or locations.

if (!TiBeacons.checkAvailability()) {
    //alert('Either Bluetooth is turned off, or your device does not support Bluetooth LE');

    var alertDlg = Ti.UI.createAlertDialog({
        title : 'Bluetooth LE Required',
        message : 'Please enable Bluetooth',
        buttonNames : ['Cancel', 'Open Settings'],
        cancel : 0
    });

    alertDlg.addEventListener('click', function(e) {
        if (!e.cancel) {
            var settingsIntent = Titanium.Android.createIntent({
                action : 'android.settings.BLUETOOTH_SETTINGS'
            });
            Ti.Android.currentActivity.startActivity(settingsIntent);
        }
    });

    alertDlg.show();
}

Obviously this only works for Bluetooth, but as you now need location, you will need to do the a similar thing for Locations.

@Astrovic
Copy link
Author

Astrovic commented May 2, 2016

Thank you very much for the advice! It is an excellent solution :)

@roelandp
Copy link

@rwuttke would be great if you could provide the complete fix... With the updated radius.jar etc? I've implemented this in an app which already asked for location for other purposes, so I'm curious it will work out of the box, with targetSDK 23 ....

I guess posting your updates as pull-requests would really help me and some others... Maybe even a new dist-version, eg. 0.5?

kind regards, roeland

@rwuttke
Copy link

rwuttke commented May 16, 2016

@roelandp I will try to find some time ASAP to get that done.

@tityrus
Copy link

tityrus commented May 19, 2016

The current code in the repository doesn't work with Android SDK 23 + Titanium SDK 5.2.0.GA either. We made some changes to get that working, but haven't tested on Android 6 with the new permissions system.

So @rwuttke if you can do the update for Android 6 permissions then great. If not I might be able to help at least with SDK 23 + Titanium 5.2.0.GA support.

@roelandp
Copy link

Really?

I have built this module inside Android 6 (targetSDK 23) and had it checked via one of our testers with a Nexus 5x Android 6.0.1.

In the given app I have a check whether the 'bluetooth' is enabled / BLE works:

Ti.API.info(TiBeacons.checkAvailability());
Ti.API.info(TiBeacons.isReady());

This does actually work and respond upon switching bluetooth on / off (returns either a true / false) and I run this on the given page in a interval (up to a minute) and kills the interval whenever bluetooth is switching on. (and sets the color to 'green' and text to 'Bluetooth OK').

But I must say I do have the new android permissions in this app already built in at a earlier level for:

  • Geolocation
  • Filewrite

Because I mainly use this for 'GPS'-based tours.

Kind regards, Roeland

On 19 May 2016, at 18:53, Joris [email protected] wrote:

The current code in the repository doesn't work with Android SDK 23 + Titanium SDK 5.2.0.GA either. We made some changes to get that working, but haven't tested on Android 6 with the new permissions system.

So @rwuttke https://github.com/rwuttke if you can do the update for Android 6 permissions then great. If not I might be able to help at least with SDK 23 + Titanium 5.2.0.GA support.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub #17 (comment)

@PietroGranati
Copy link

Hi everyone, I've noticed the same problem, form me android seems to see the region but not the beacons.

In fact an android 5 fires the event "proximity" but android 6 no

@appinlet
Copy link

appinlet commented Sep 14, 2017

@PietroGranati @roelandp @Astrovic @rwuttke

I've got the module working in a new Android app on version 6 using 6.2.0.GA and my rebuilt module at: https://github.com/RBAtkins0n/liferay-android-beacons

I have this code inside the app to request permission:

if (OS_ANDROID) { var permissions = ['android.permission.ACCESS_FINE_LOCATION']; Ti.Android.requestPermissions(permissions, function(e) { if (e.success) { Ti.API.info("SUCCESS"); } else { Ti.API.info("ERROR: " + e.error); } }); }

And this is what I've got in my tiapp.xml (some of these entries are specific to my app and may not be needed).

<android xmlns:android="http://schemas.android.com/apk/res/android"> <manifest package="MY.APP.ID"> <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="26"/> <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <application android:theme="@style/apcelerator"> <service android:enabled="true" android:exported="true" android:isolatedProcess="false" android:label="iBeacon" android:name="com.radiusnetworks.ibeacon.service.IBeaconService"/> <service android:enabled="true" android:name="com.radiusnetworks.ibeacon.IBeaconIntentProcessor"> <meta-data android:name="background" android:value="true"/> <intent-filter android:priority="1"> <action android:name="com.appinlet.example.DID_RANGING"/> <action android:name="com.appinlet.example.DID_MONITORING"/> </intent-filter> </service> </application> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.GET_TASKS"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> </manifest> </android>

@appinlet
Copy link

Instructions are added to the docs.

@jamesfalkner this issue can be marked resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants