I want to know if the device has GPS or not, how could I do that for the devices below v 5.0 ?
Have a look at docs for Location Provider. Try this code on a few devices in different situations and I think it should work:
try {
LocationProvider lp = LocationProvider.getInstance(null);
if (lp == null) {
//Device doesn't currently have GPS enabled
} else {
//Device has GPS enabled
}
} catch (LocationException le) {
//Device's GPS is currently permanently disabled
}
You have to check if Java ME's JSR 179 is available.
Related
im using ionic native ibeacon library to detect beacons.I can detect beacons with android but when I try in ios ,i always see an empty beacon array.
I tried these things ,but still cant see the beacons in ios (device is iphone 6s plus 11.4.1) (bluetooth service is enabled on device)
I tried both requestWhenInUseAuthorization and also
requestAlwaysAuthorization.
I add NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription key in info.plist
my code is like this, its working on android device
import { Injectable } from '#angular/core';
import { Platform, Events } from 'ionic-angular';
import { IBeacon } from "#ionic-native/ibeacon";
#Injectable()
export class BeaconProvider {
delegate: any;
region: any;
constructor(
public platform: Platform,
public events: Events,
private iBeacon: IBeacon
) {
this.initialise();
}
initialise(): any {
let promise = new Promise((resolve, reject) => {
if (this.platform.is("cordova")) {
this.iBeacon.requestAlwaysAuthorization();
// ALSO try this one too this.iBeacon.requestWhenInUseAuthorization();
this.delegate = this.iBeacon.Delegate();
this.delegate.didRangeBeaconsInRegion().subscribe(
data => {
this.events.publish("didRangeBeaconsInRegion", data);
//console.log("didRangebeacons__" + JSON.stringify(data)); // empty beacons array
},
error => console.error()
);
this.region = this.iBeacon.BeaconRegion("deskBeacon", "e2c56db5-dffb-48d2-b060-d0f5a71096e0");
this.iBeacon
.startRangingBeaconsInRegion(this.region)
.then(
() => {
resolve(true);
},
error => {
console.error("Failed to begin monitoring: ", error);
resolve(false);
}
);
} else {
resolve(false);
}
});
return promise;
}
}
EDIT
My location services are on ,and I'm using same uuid in ios or android (ionic,same code).By the way I tried to make a iphone as beacon transmitter by an app in market,other iphone can see it as beacon.
And here is the screenshot of beacon scope app
A few things to check on iOS:
Go to settings, location, and check if your app has been granted location permission.
Make sure Bluetooth is turned on
Try a 3rd party beacon scanner like Locate Beacon, configure it with your UUID and make sure it can detect your beacon with the same device.
EDIT: A few more steps
Make sure iOS has Location turned on in Settings (the overall setting, not just for your app) Settings -> Privacy -> Location Services
Since you can detect on Android but not iOS, double check the UUID that you see on Android and make sure it matches exactly what you enter on iOS.
If the UUID in the config matches, but it still won't detect, verify that the beacon is actually sending out an iBeacon frame and not AltBeacon or some format iPhone won't see by default. If you use the Beacon Scope app for Android, it will tell you the frame type.
I need to search nearby by bluetooth device those are classic Bluetooth (Bluetooth 2.1 or later). I searched a lot but there are only library and discussion about the BLE any guidance will help me a lot.
As far as I know, you can't find them until you don't manually pair and connect them. In order to discover the already paired and connected ones, I use this:
import AVFoundation
func example() {
let session = AVAudioSession.sharedInstance()
do {
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.allowBluetooth)
if let inputs = session.availableInputs { ... } //should contain bluetooth devices aswell
}
catch { print("Failed to set category") }
}
`
I am using Core Motion Framework for detecting the device activity.
i.e. Walking, Running, Automotive, Stationary
The main issue is i am able to detect walking and running with great accuracy but my device is not able to detect the Automotive mode.
Here is my code
var motionActivityManager: CMMotionActivityManager?
if CMMotionActivityManager.isActivityAvailable() {
motionActivityManager?.startActivityUpdatesToQueue(NSOperationQueue.currentQueue()!, withHandler: {
activityData
in
if activityData!.walking == true {
self.lblActivityStatus?.text = "Walking"
} else if activityData!.running == true {
self.lblActivityStatus?.text = "Running"
} else if activityData!.automotive == true {
self.lblActivityStatus?.text = "Automotive"
} else if activityData!.stationary == true {
self.lblActivityStatus?.text = "Stationary"
}
print("Activity Data: ", activityData)
})
}
I finally got the answer by testing the same app on multiple devices.
the m7 chip on first generation device is not working properly for particularly "Automotive" mode.
When i was testing on 5s and ipad air, it was not detecting Automotive mode as it should detect. But testing the same app with iphone 6 Plus, it worked fine.
so the problem was with device not with framework.
I have successfully acquired location in my BlackBerry through the criteria;
BlackBerryCriteria myCriteria = new BlackBerryCriteria(LocationInfo.GEOLOCATION_MODE)
The location was acquired in the following scenario:
No mobile coverage on the BlackBerry handset
Active internet connection
No GPS fix
My question is what is this location that is acquired - GPS or Cell Tower Triangulation?
I believe since the location is acquired indoors without any GPS fix, it should be a Cell Tower location. I do not have mobile coverage yet the location is acquired. How is the cell tower information obtained then? If I was using a roaming GPRS connection, would the location obtained be any different (based on the IP settings)? For reference, below is the complete code of obtaining the location:
try
{
BlackBerryCriteria myCriteria = new BlackBerryCriteria(LocationInfo.GEOLOCATION_MODE);
try
{
BlackBerryLocationProvider myProvider = (BlackBerryLocationProvider)
LocationProvider.getInstance(myCriteria);
try
{
BlackBerryLocation myLocation = (BlackBerryLocation)myProvider.getLocation(30000);
double _longitude = myLocation.getQualifiedCoordinates().getLongitude();
double _latitude = myLocation.getQualifiedCoordinates().getLatitude();
setLocation(new Coordinates(_latitude, _longitude, 0.0f));
}
catch (InterruptedException e)
{
showException(e);
}
catch (LocationException e)
{
showException(e);
}
}
catch (LocationException e)
{
showException(e);
}
}
If I'm reading your description correctly:
No mobile coverage on the BlackBerry handset
Active internet connection
No GPS fix
you must have a Wi-Fi connection then (active internet, but no mobile coverage).
So, the device is then using Wi-Fi geolocation (aka WLAN geolocation), which was added a bit late in the development of BlackBerry Java (although, it's still been available for a while ... OS 6.0+).
http://devblog.blackberry.com/2011/09/wifi-geolocation-launch/
Obviously, the test is to turn off your Wi-Fi, and see if you still get location fixes.
I'm able to connect to a webservice and download the data using a variety of devices, such as the BlackBerry 9000 with OS 4.6 or greater.
However, with the 8330 and OS 4.5.0.77 it doesn't work. I have not tried this code on any devices older than the 8330 with 4.5.0.77.
On the 8330 it hangs on the resultObj = op.invoke(inputObject); line in the JSR172 webservice call. This is after making the first webservice call successfully -- it hangs on the second.
There are actually two webservices:
The webservice used for authentication.
The webservice used to download all the information.
Things I've tried thus far:
Wiping the device - did nothing
Connecting the device to Eclipse to see what is going on - didn't find anything useful
Running the code on a 8330 simulator with 4.5 (MDS running)- works flawlessly with no problems
Does anyone know how to fix this issue?
Here is how I build my connection string:
String webserviceURL = developmentUrl;
// if it is simulator then force the network that is available on
// the PC
if (DeviceInfo.isSimulator()) {
webserviceURL += ";deviceside=true";
} else if ((CoverageInfo.getCoverageStatus() & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) {
// go through MDS
webserviceURL += ";deviceside=false";
}
// else if ((CoverageInfo.getCoverageStatus() &
// CoverageInfo.COVERAGE_CARRIER) == CoverageInfo.COVERAGE_CARRIER)
// {
// webserviceURL += "'deviceside=true";// go direct
// }
// check if the wifi is available and change the url to use the wifi
// signal
if ((RadioInfo.getActiveWAFs() & RadioInfo.WAF_WLAN) != 0)
// check for carrier
{
if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
// check for wifi
{
// WebService URL when the app is being used in the
// actual device
webserviceURL = webserviceURL + ";interface=wifi";
}
}
// WebService URL when the app is being used in the actual device
_propertyValues = new Object[] { webserviceURL };
I was able to solve this problem by going to ~50k chunks for the data. I'm happy to help anyone who has a similar issue.