I'm working on a Control Extension for Sony SmartWatch 2 that needs to update a TextView every second on the SW2 Display.
It happens that if I've my Smartphone connected via USB or when USB disconnected if I've my Smartphone screen active, the Control Extension works as expected on SmartWatch 2.
But soon my SmartPhone screen idles, the control extension stops the regular TextView updates. First starts breaking and eventually get stuck. The Extension is not closed by the Host Application and the SW2 continues well paired with the Smartphone. In fact if I touch the display, the Extension appears to recover state for some moments with a few TextView updates, but rapidly breaks and get stuck again.
Meanwhile, if I turn ON my Smartphone screen, the control extension recovers the state and resume the normal TextView updates.
It seems that when the smartphone idles it stops to send the regular bluetooth messages to the SW2. I've tried many solutions to avoid this behaviour, even set the keepRunningWhenConnected to true. But the behaviour is allways the same.
Is anyone also having this problem or have a clue for the solution?
Thanks :)
What model of phone are you using?
If it is indeed that the bluetooth connection is not persisting then you could try the following possible solutions:
Is there a setting on the phone to keep bluetooth on even when going into idle?
You could set the phone to not go into idle while your app is running, of course this is not ideal as it will cause battery drain.
Ok. After testing and testing several solutions (AlarmManager, BluetoothAdapter, etc...) I came to following conclusion:
Its not the Bluetooth connection that is lost, otherwise the SmartWatch 2 would lost connection with the Smartphone, and that never happens. In fact is the Phone CPU that is lost by the ControlExtension, because when the Smartphone idles the CPU also idles. By loosing the Phone CPU the ControlExtension cannot process the "sendText(...)" call and this means that the corresponding upper call "sendHostApp(...)" that uses the Bluetooth messages its also never called, that's why the TextView is not updated on the SmartWatch 2.
Also I think that when I touch the SmartWatch 2 screen, this triggers an hardware interruption that wake up the Phone CPU for short seconds to answer to the SmartWatch 2 Touch Event and thats why when I touch the SW2 screen the TextView is updated a few times before get stuck again.
This works fine for static Control Extension applications that only display static content and/or replies to the user (touch, swipe, etc...) events. But its a complete disaster for Control Extensions applications that need to be doing some processing regardless the user direct interaction.
I never though in this terms because I though that it was the job of the SmartConnect Host Application to guarantee Phone CPU to the Control Extensions.
So the solution for some apps could be using an AlartManager in order to schedule wake up calls to do some processing. For other apps the solution could be the PowerManger and use a wakelock.aquire()/wakelock.release().
Related
Since the latest update (I think some time in December 2022), the built-in camera app on my Samsung Galaxy S21 asks for "Nearby devices" permission, and refuses to run if I don't grant it. By "Nearby devices" it means "Bluetooth". I don't know why it calls the permission
"Nearby devices": all other references to Bluetooth call it "Bluetooth",
and you can also access a nearby device using Wi-Fi or even NFC if the device
is close enough.
It doesn't actually need Bluetooth to take photographs, or even to record movies,
but you might have a Bluetooth microphone (I don't) and you might want to use
it to get better sound quality when recording a movie.
Of course the Android best practice advice at
https://developer.android.com/guide/topics/permissions/overview
is not to ask for runtime permissions unless and until you need them,
but Samsung aren't doing that.
I don't want the camera app to announce my presence by probing the Bluetooth headset of
anyone who happens to be near me, and they might regard such an action as intrusive.
So I don't want to give the camera app its nearby devices permission, but it won't
run at all without it.
So how do I get the camera app to run without accessing Bluetooth?
I found some workarounds for this. If your device supports it, you can download Expert Raw from the Galaxy Store. This will take still photos without requiring "Nearby devices" permission. However it doesn't seem to be able to do selfies because there seems to be no way to switch cameras, and it can't do movies or many of the extra tricks that the full camera app can do.
Another option is to run the camera app with Bluetooth disabled. Then it can have its "Nearby devices" permission, but it can't use it. The problem with this is that if you use Bluetooth at other times you have to remember to disable it and enable it.
So I wrote a tiny app which disables Bluetooth, runs the camera app, and restores the previous enabled or disabled state of Bluetooth when the camera app exits. I put this on my home screen instead of the camera app: it has the same icon. You have to remember to exit properly from the camera app using the Back button: the Home or Recents buttons leave my app and the camera app sitting on the task's back stack, so my app doesn't get to run and restore the Bluetooth state.
The app is available on github here in case anyone else wants to use this solution.
I am attempting to write a small helper app for macOS that captures the input of a Nimbus Steel Series game controller and converts it to keyboard and mouse events for another application (a game that does not support controllers).
In my first attempt I used GCController but as soon as the app becomes inactive no more events are received from the controller. There seems to be no way to change this.
In my second attempt I used CBCentralManager to discover the controller, hoping I could work with it using standard Bluetooth services. But the controller does not even show up in a scan, either with the controller being connected or disconnected. I find devices around the house (iPads, iPhones, smart tv's, computers), but no peripheral that identifies itself as Nimbus. However, there are a couple nil peripherals which I suppose are auxiliary peripherals from Apple devices such as the Magic Mouse or the Wireless Keyboard.
In my third attempt I tried to make the main window an NSPanel in HUD style. The panel stays afloat but it still becomes inactive when I click elsewhere. No controller events received. I thought maybe I could show the panel above the fullscreen game in a corner somehow. But it still needs to be active to get GCController events, then the game would not get events.
Are there any other options to receive game controller inputs which the app is inactive?
Would it work via IOKit? I have been hesitant to use IOKit so far because I was hoping to resolve this issue without it, being a very lowlevel API.
I solved this problem using the IOHIDManager functions. The callbacks receive events even if the app is not active.
I am aware of MOTO G first version has bluetooth issues.
Background:
My app scans for beacons in the vicinity. The app works great on all Android phones except Motorola Moto G, 1st version with Android 5.1. On this phone, it finds all the beacons except one and the scanning is pretty fast as well. However, with this specific beacon (skybeacon), it only detects first packet and after that it takes forever to find this specific beacon while finding others. A simple conclusion is this specification beacon has issues, which might be true. However, it becomes more interesting from here.
To understand this more, I downloaded other BLE scanners from play store. When I used "BLE Analyzer" from bluevoid, it captures this beacon perfectly. I can see RSSI changing as I move the beacon and it is pretty fast. Once I push BLE Analyzer to background and check our app, surprisingly our app works now. I repeated this, 20/20 times my app captures this specific beacon as long as BLE Analyzer is pushed into background (by pressing home button). If I restart or uninstall or wont open BLE Analyzer at all, my app wont capture this specific beacon.
Possible explanations:
For good or bad this specific beacon is advertising in one channel and the default scanning on this specific phone is having a mismatch. If this is in the right direction, then how to change default scanning channels through app?
This phone might have an integrated chip for wifi, bluetooth and 3G, which might be true. When I disable wifi, I do not see any changes in behavior. When I disable data (3G, not 4G on this), it some times (2 out of 10) start capturing the skybeacon. Again 2 out of 10 times is not a repeatable solution.
Any thoughts?
With the update of iOS 7.1 there is much changes in the ibeacon API for requesting, ranging beacon in the background even when app is killed or not launched, here are some of the things i observed as per the ranging for the beacons , in iPod 5th gen running with iOS 7.1
didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
doen't get called, but where as i run the same code in iPhone5 with 7.1 all the methods were getting called, its kind of a weird behaviour i'm facing,
http://www.proxima.io/blog/posts/2014-03-12-ios-7-1-ibeacon-tech-deep-dive/
as per the above link , it gives me something like there is not much update about ibeacon for the iOS7.1 in iPod 5th generation
Does any one faced this kind of same issue?
Be sure you wait up to 15 minutes to get a call to didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region before you conclude it does not work. On some devices, detection cash take that long. See here. Do not expect calls to be received on both devices in a similar time frame. One may be fast and the other slow based on model and internal state.
Other tips: try rebooting both devices to put them in the same state, and verify the problem persists. Avoid running other iBeacon or Bluetooth apps simultaneously, as this can affect your test results. I do not have access to an iPod for testing, but I know other folks report (including those at the page you reference) that iPods work fine with these APIs
I wish to know how to generate local notification alerts similar to apple's clock alarm (that comes with the iPhone) while my application is the the background and/or the iPhone is closed. Currently I gets a single vibration and a single play of my ringtone. This is not sufficient and must run in loop till having user response. So how the did it in Apple? TNX.
They used private APIs that are not accessible to normal developers like you and I. The best you're going to get is that one ring and one vibration, unless you're not going for distribution in the App Store.