significantLocationChangeMonitoringAvailable not working on iOS 4 - ios4

I have the following simple code which looks if the device has a support for significant Location Change Monitoring:
if (![CLLocationManager significantLocationChangeMonitoringAvailable])
{UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Sorry" message:#"Your device won't support the significant location change." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
return;
}
This always returns yes on iOS 5 device but returns NO on iOS 4.3 device. The devices have 3G in it.
This API is supported from 4.0 as per the documentation.

The API is supported, but the feature isn't supported until iOS 5 and above.

Related

Writing a notification descriptor value in iOS using bluetooth

I'm using Plugin.BLE to iterate a bluetooth device's services / characteristics / descriptors. When I find the descriptor I'm looking for, I try enabling notifications by writing 02-00 into the descriptor. This works for Android devices but on iOS, I get a an error:
Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Client Characteristic Configuration descriptors must be configured using setNotifyValue:forCharacteristic
The offending C# code looks like:
await descriptor.WriteAsync(new byte[2] { 02, 00 });
Is there a different way on iOS devices to enable notifications?
It is apparent that this is one of those platform specific issues that will have to be refactored out into an interface / platform-implementation pattern. So for the iOS version of the application, in order to do the above, I had to write against CoreBluetooth. Once you have your device / service / characteristic / client configuration descriptor, you call the following:
peripheral.SetNotifyValue(true, characteristic);
After setting that value, a callback is issued to the peripheral delegate:
public override void UpdatedCharacterteristicValue(CBPeripheral peripheral, CBCharacteristic characteristic, NSError error) { }
From there I was able to continue what I was doing before.

Handling UIBackgroundTask Expiration is stopping my beaconRanging Method

i developed an app which ranges for beacons in the background using ibeacon API. As it uses the core location and bluetooth , so i enabled the Location, Bluetoothconfiguration from the capabilities. So after running my app , ranging happening in background, but after 5-10 min between my app terminates, when i launch the app it is again showing the splash and the login page, so after google i learned that app runs in background with some extra time.
To overcome the app termination i'm using the below code in a method and calling that method in applicationDidEnterBackground.
-(void)startBackgroundTask
{
if(bgTask != UIBackgroundTaskInvalid)
{
[[UIApplication sharedApplication] endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}
bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[self endBackgroundUpdateTask];
NSLog(#"your time is over");
//you can call start once again to get more time
}];
}
-(void) endBackgroundUpdateTask
{
[[UIApplication sharedApplication] endBackgroundTask: bgTask];
bgTask= UIBackgroundTaskInvalid;
[[NSNotificationCenter defaultCenter]
postNotificationName:#"TimerOutStartMonitering" object:nil];
}
After using the above code and debugging , my app ranging stops once the UIBackgroundTaskInvalid. How can i achieve the both tasks 1)My App shouldn't terminate once the background time is finished.
2)My ranging for beacons shouldn't stop.
Is it possible?
Please help me out.
Unfortunately, this is not possible. You cannot run a background task like this indefinitely. This mechanism is only intended for short term app cleanup before termination. See here.
Apps running background tasks have a finite amount of time in which to run them. (You can find out how much time is available using the backgroundTimeRemaining property.)
Because of this, iBeacon ranging is limited to a few seconds in the background. You can use IBeacon monitoring to relaunch your app and range again on beacon discovery, but again, you will only get a small of ranging time unless the user brings the app tyo the foreground.

Setting Core Data persistent store (SQLite) as NORMAL locking-mode

I'm building a prototype of an app where persistent store uses SQLite via AFP on a "server" machine (the same LAN).
However, I can't connect to the store from 2 different instances of my app.
I set SQLite pragma setting (related to locking) on persistent store coordinator like this:
NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
NSMutableDictionary *pragmaOptions = [NSMutableDictionary dictionary];
[pragmaOptions setObject:#"NORMAL" forKey:#"locking_mode"];
NSDictionary *storeOptions = [NSDictionary dictionaryWithObject:pragmaOptions forKey:NSSQLitePragmasOption];
if (![coordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:storeOptions error:&error]) {
[[NSApplication sharedApplication] presentError:error];
return nil;
}
and error message I'm getting when trying to connect to the store from 2nd client (i.e. when the 1st one is already successfully connected) is:
ERROR: sqlite database is locked because it is in use by another host that holds a host-exclusive lock on .../TestDBApp.storedata; this host UID... cannot override the host-exclusive lock until the other host UID... releases its locks on .../.TestDBApp.storedata-conch
Am I doing something wrong?
Is accessing the same store from 2 clients possible with Core Data and SQLite?
Is this a bug in Core Data and/or SQLite API?
SQLite does not allow a database file to have multiple write locks. Write locks are taken for any transaction that changes data, or when the applications explicitly requests one.
Apparently, a Core Data connection holds a write transaction or a write lock open.
As far as I could remember, Core data will use the exclusive lock mode for save method. I suggest you to pass argument "-com.apple.CoreData.SQLDebug 1" to your app . If you find "BEGIN EXCLUSIVE" in console, I guess your setting is ignored by Core Data.

How to get information about CONNECTED bluetooth device for android?

If I have a Android phone which is already connected with a bluetooth headset (paired and connected) to it.
How I can get information about that specific headset.
Using getBondedDevices() method I get list of all paired devices..I need information about CONNECTED device only.
I can not wait for broadcast receiver to check status, because I need this information at the start of my application. So please suggest is there any way to get this information without waiting for broadcast.
You can do this through the IBluetoothA2dp interface in API 11 and up. Some more info on there is here: Android connect to a paired bluetooth headset
Here is a great resource to see the difference in what is available to this interface between API 10 and 11 where it changed quite a bit.
http://grepcode.com/file_/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/bluetooth/BluetoothA2dp.java/?v=diff&id2=2.2_r1.1
Hope that helps.
You can use the getConnectedDevices for the HEADSET Profile to get the device to which it is connected.
Check this out to see if headset is connected (ICS only):
public boolean isVoiceConnected()
{
boolean retval = true;
try {
retval = BluetoothAdapter.getDefaultAdapter().getProfileConnectionState(android.bluetooth.BluetoothProfile.HEADSET) != android.bluetooth.BluetoothProfile.STATE_DISCONNECTED;
} catch (Exception exc) {
// nothing to do
}
return retval;
}

Data not getting saved using RMS

In my j2me app, I write data using this:
RecordStore rs = RecordStore.openRecordStore("mydb", true);
String buf = "Some text";
rs.addRecord(buf.getBytes(), 0, buf.getBytes().length);
rs.closeRecordStore();
The data stays as long as the app is running, but when I restart the app, there is no "mydb"
I tested it on emulator and device both. I know there can be some problems in emulator but it should work on the device at least.
I'm using:
Java Me SDK 3.0
CLDC 1.1
MIDP 2.0
Device: Samsung S5620
OS:Vista
Is it related to some permissions or the app should be signed before running?

Resources