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

discovery on Marshmallow #55

Open
sixbladeknife opened this issue Jul 19, 2017 · 1 comment
Open

discovery on Marshmallow #55

sixbladeknife opened this issue Jul 19, 2017 · 1 comment

Comments

@sixbladeknife
Copy link

sixbladeknife commented Jul 19, 2017

hi,
I am experiencing issues while discovering devices using Android MArshmellow. It simply fails on discovery anything...I read about the permissions over location (coarse and fine) that should be put into the manifest and programmatically. However, I had no luck up to now.
Any advice about getting rid of this issues? is a version that deals with this problem on schedule? I'm currently using version 0.5.1.

sbk

@sixbladeknife
Copy link
Author

Eventually I've found a sort of a workaround. I won't create a pull request as it would require the installation of the cordova plugin cordova-plugin-android-support-v4.
Basically the modification I did was merely this, in BCBluetooth.java:

public boolean execute(final String action, final JSONArray json,
			final CallbackContext callbackContext) throws JSONException {
                       
                       /* ...omissis...*/

			if(action.equals("startClassicalScan")){
				Log.i(TAG,"startClassicalScan");
				if(bluetoothAdapter.isEnabled()){
					try{
						if(((android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)) && //23 >=21 for zonta's tablet
						 (!cordova.hasPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION))){
							if (!cordova.getActivity().shouldShowRequestPermissionRationale(android.Manifest.permission.ACCESS_COARSE_LOCATION)) {
								cordova.requestPermissions(this,100,
										new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION});
							}
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					if(bluetoothAdapter.startDiscovery()){
						callbackContext.success();
					}else{
						callbackContext.error("start classical scan error!");
					}
				}else{
					callbackContext.error("your bluetooth is not open!");
				}
			}
                                              
                       /* ...omissis...*/
	}

hope it helps

sbk

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

1 participant