How to read from Bluetooth barcode scanner hardware device - android

I've been trying to get a piece of code to connect to a bluetooth bardcode reader I bought and have tried almost every library in Android Arsenal.
Currently, I am using this one: https://github.com/MacroYau/Blue2Serial
I have all permissions in my manifest:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
I also request permission when the app opens:
ActivityCompat.requestPermissions(this,
new String[]{android.Manifest.permission.BLUETOOTH,
android.Manifest.permission.BLUETOOTH_ADMIN,
android.Manifest.permission.BLUETOOTH_PRIVILEGED,
Manifest.permission.ACCESS_COARSE_LOCATION},
0);
I am able to connect to the scanner device from the app, it pairs up ok. But, when I scan something, I don't see the public void onBluetoothSerialRead(String message) method firing up. It was exactly the very same with all the other libraries I tried. I could pair up, but not read it.
Conversely, if I open a notepad type of app in the same phone and scan it, the contents are immediately written to the notepad.
The scanner device I am using is this one: https://www.zebra.com/us/en/products/scanners/companion-scanners/cs4070.html
Anyone with some tip to give me?
Thank you!

I can think of a few things.
(1) You are reading a 'poorly designed' 2D barcode. Some of the older 'standard' barcodes have simple checksums so lots of random data using a laser based scanner can actually result in a decoded value. If I recall correctly Interleaved 2 of 5 was one of those.
(2) If you enabled 'read all barcodes' its possible that the sub-sequence of codeword (white and black spaces) maps to a valid barcode definition. I would only enable those 2D barcode types that you would be be actually reading.
(3) On the Android side your Bluetooth serial reader isn't picking up the data fast enough. This can be mitigated with the scanner sending prefix/suffix values so that the app knows if you don't get those it was a transmission error.

Related

Solved - Beacon Library - Unable to Obtain Bluetooth Permission on Xiaomi Phones + Only detects beacons when app is hidden in background

## How I solved it:
### For Permissions: Make sure to request Background location too:
```Java
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
For Verifying Permissions:
Copy the whole snippet from:
https://altbeacon.github.io/android-beacon-library/requesting_permission.html
to your on create method
BE PATIENT!!!!
Apparently, it takes about 1 minute for the first detection (both monitoring and ranging) to occur despite me setting the ranging time to 5 seconds (5000 ms). After that, the response time for out of range beacon should be less than half a second.
Please Advice if you can help with the long waiting time between starting the monitoring to receiving a list of beacons detected despite a change in beacon detection state already within 1 second of starting monitoring.
Original Question
Extra Detail:
The detection goes smoothly even if the 'Change Bluetooth Permission' mentioned above is set to 'notify' whenever I switch to another app despite the app not being a service. Why is that?
Original Question:
I am trying to scan for beacons around me using the android beacons library and it never works unless I manually go into settings -> manage apps and change the 'Change Bluetooth Connectivity (turn Bluetooth on or off)' permission from 'notify' -> to 'Accept'
However, I already requested bluetooth and bluetooth admin permissions
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
as well as other permissions like fine location/coarse location
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
The previous app that I created worked fine on my device but in that app, the beacon functions are built as a 'service' and I have heard that requesting Location permission when running beacon functions not as a service can spell disaster. However, removing the location permissions did not make a difference upon my experimentation. It is only manually changing the bluetooth permission in settings that made it work.
So the question is, how to I force the general bluetooth permission on a Xiaomi phone to ACCEPT through a prompt like requesting dangerous permissions for coarse location requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1234);
and is this the right way to solve the issue? Many thanks
Device:
Xiaomi Mi8 (MIUI11 Android 10 API29)```

Uno-Platform permission problems for android development

I am new to the Uno-Plaform development scene and i wanted to create my own speech recognition.
The setup of my speech recognition works with cortana and UWP,
but the setup for my android phone has been creating some problems.
I have added these lines of code to my Android manifest:
AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
With these lines of code i should technically be able to record my audio coming from my phone.
System.Exception: 'Error during speech recognition: InsufficientPermissions'
But this is the Exception i get after running it on my android device.
After looking into the android i have found out about dangerous permissions and that these are the cause of my problem.
After many hours of research and testing i have not found a way to open a permission prompt so that i am allowed to use my microphone.
Can anyone explain or help me out with this problem?
Thanks in advance!
Since it's a common requirement, Uno actually offers a few extension to make it easy to request for permissions on Android.
This code is only available on Android
#if __ANDROID__
// This will only check if the permission is granted but will not prompt the user.
bool isGranted = await Windows.Extensions.PermissionsHelper.CheckPermission(ct, Android.Manifest.Permission.RecordAudio);
// This will prompt the user with the native permission dialog if needed. If already granted it will simply return true.
bool isPermissionGranted = await Windows.Extensions.PermissionsHelper.TryGetPermission(ct, Android.Manifest.Permission.RecordAudio);
#endif
Source of that extension is available here

Sending an image via Bluetooth from android to a pc

I have just starded to work with Android and I have to create an app that takes a picture and then sends it to a pc via bluetooth.
The problem is when I have to send the image, because I can't find a simply code to do this.
I can have everytime the uri of the picture I took before, so i need a code that searches for the active devices near mine and then sends the picture to the one of them I choose.
Please help me!
Thank you
For discovering nearby bluetooth devices, you can refer following links which will help you to understand it better:
http://developer.android.com/guide/topics/connectivity/bluetooth.html#FindingDevices
http://developer.android.com/guide/topics/connectivity/bluetooth.html#DiscoveringDevices
And if you want to Enable device bluetooth without asking the user. You can use this in your manifest file.
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
You need to understand BluetoothServerSocket Programming in android.
http://www.programcreek.com/java-api-examples/index.php?api=android.bluetooth.BluetoothServerSocket
Follow this link ... Hope this will help you.
https://developer.android.com/guide/topics/connectivity/bluetooth-le.html
Follow this link to understand bluetooth in android.

can't place call from webpage in android app

I have an app that points the user to a webpage with a phone number in it. But when trying to call from the phone number I get an error message.
For the Android manifest, I tried to request phone permissions with both
<uses-permission android:name="android.permission.CALL_PHONE" />
and
<uses-feature android:name="android.hardware.telephony" android:required="false"></uses-feature>
Neither work.
The error message I get is The web page at tel:(the phone number) might be temporarily down or it may have moved permanently to a new web address.
So what am I missing here?
Ensure that the html link for the phone number is something along the lines of:
Call us now!

Appcelerator Android app starts crashing when Internet is turned Off

I am working with Titanium Appcelerator 1.8.1 Android SDK. App is working perfect when Internet connectivity is on. But when I turn the connectivity is off, App crashes in the start. Nothing works as expected. I am supposed to develop offline feature, which enables app to be working as expected when it's offline and syncs data when it is online.
I had used following permission set:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CALENDAR"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Branch your logic like
if(Ti.Network.online){
//sync data
}else{
/fetch data from local persisitance
}
And FYI i guess Titanium takes care of adding these permissions to the manifest file by default.
That may be caused by the "Live view" option activated, it need the mobile to be in the same network as the PC where Appcelerator is running. If you are developing an offline app, you have to unselect that option, that way you can run your app without beeing in the same network as the PC.
Image of Live View option

Categories

Resources