Xamarin Forms Labs Geolocation sample - android

I downloaded the source for Xamarin Forms Labs, and was trying to run the geolocator sample for the android project. When you click the Get Position button, the location message returned is "Cancelled". I tried making a new xamarin forms project in VS by following these steps: file > new project > Xamarin PCL. When I install xamarin forms labs in that project and use it, I get the same message. I can, however, get the Windows Phone example to work. I'm not sure if maybe the Android emulator that installs with Xamarin can even connect to the network on my machine or not. That would explain why it cant get the location

(This is a little late, but just submitting in case anyone finds this via a search)
Double check your platform permissions.
For Android:
You must request the following permissions within your Android Project
ACCESS_COARSE_LOCATION
ACCESS_FINE_LOCATION
For iOS:
In iOS 8 you now have to call either RequestWhenInUseAuthorization or RequestAlwaysAuthorization on the location manager.
Additionally you need to add either the concisely named NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription to your Info.plist.
For Windows Phone:
You must set the ID_CAP_LOCATION permission.
Xamarin Forms
If you are developing a Xamarin Forms app, you could try using the Geolocator (Xamarin.Plugin) sample, just remember to add your permissions :)
Sample:
var locator = CrossGeolocator.Current;
locator.DesiredAccuracy = 50;
var position = await locator.GetPositionAsync (timeout: 10000);
Console.WriteLine ("Position Status: {0}", position.Timestamp);
Console.WriteLine ("Position Latitude: {0}", position.Latitude);
Console.WriteLine ("Position Longitude: {0}", position.Longitude);

Related

Is Expo Pedometer supported on Android?

I'm setting up a Pedometer app in React Native using Expo, testing the code on my real Samsung s10 device.
I am using the Expo Pedometer documentation
However, when I use the Pedometer.getStepCountAsync method, I get returned an error "Getting step count for date range is not supported on Android yet."
I am trying to make a pedometer app that reads users steps, and then puts them into some visuals for the user but I can't get the steps data.
My code is below: it reaches the error => line and returns the error mentioned above. :(
I've enabled the Fitness API in my Google Developer Console and am 99% sure I have the right credentials; as I have used the Google Login successfully in the same app.
const end = new Date();
const start = new Date();
start.setDate(end.getDate() - 1);
Pedometer.getStepCountAsync(start, end).then(
result => {
this.setState({ pastStepCount: result.steps });
},
error => {
this.setState({
pastStepCount: "Could not get stepCount: " + error
});
}
);
I guess the expected result is that I get the user's steps from the past day in the result but instead I get the error that it is not supported on android.
I did something nasty as a workaround but it worked I added expo 33 as a legacy npm dependency and use only the pedometer module from there because currently they didn't implemented the pedometer functionality on android on the new Expo unimodules
package.json
"expo": "^35.0.0",
"expo-legacy": "npm:expo#33.0.0",
And use it like this
import {Pedometer} from 'expo-legacy'
Surprisingly compiled and only increased 200kb the apk size
Yes, by using Core Motion (iOS) or Google Fit (Android) to get the user's step count.
Any Android phone running on a 4.4 (KitKat) operating system or later will connect with Google Fit.
Pedometer unable to query steps, documentation unclear/contradictory.

Initialize the Fire SDK on Unity for IOS

I just started a project in Unity and I integrated FireBase Analytics.
After some problems I was able to get data from IOS and Android devices so I added some custom events.
I followed the instructions from here and I stared to see results in the dashboard . My problem is that I'm not sure if both IOS and Android are sending the events and I don't know how to separate the event in the dashboard. I'm particularly concerned because I'm not sure if I misunderstood this line of the instructions:
The Firebase Unity SDK on Android requires Google Play services, which must be up-to-date before the SDK can be used. The following code should be added at the start of your application to check for and optionally update Google Play ....
I assumed that the following code had to be added ONLY for Android so I didn't add it to IOS. Can you tell me if I had add this code for IOS too? and how can I check the events for every OS?
Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
var dependencyStatus = task.Result;
if (dependencyStatus == Firebase.DependencyStatus.Available) {
// Create and hold a reference to your FirebaseApp, i.e.
// app = Firebase.FirebaseApp.DefaultInstance;
// where app is a Firebase.FirebaseApp property of your application class.
// Set a flag here indicating that Firebase is ready to use by your
// application.
} else {
UnityEngine.Debug.LogError(System.String.Format(
"Could not resolve all Firebase dependencies: {0}", dependencyStatus));
// Firebase Unity SDK is not safe to use here.
}
});
Thank you in advance
Well, I was looking for all the day and I found that the filter between OS is in the top left corner of dashboard and event tap as well.
I also used the code for both IOS and Android and I started to get custom event in IOS too.

navigator.geolocation.getcurrentposition throws Timeout error

I'm developing a cordova application that find a particular retailer on the map near to the user's current GPS coordinates. I used the navigator.geolocation.getCurrentPosition to get the user's current position and use the Google Maps API v3 javascript to do a text search to find the retailer on the map.
I have the standard and recommended settings in both Android and iOS config files, it works find on iOS but not on Android. I exported the APK file and installed on Moto G, the application name is listed in Settings -> Location -> Current Location Requests but the browser still throws Timeout error.
Any ideas what could be wrong and why unable to detect the current position?
EDIT: To add more info, sometime the application opens up and stays blank without any timeout alerts.
You must add the geolocation plugin to your project using the following command. This sets the appropriate permissions in your platform config.xml file to allow the APK to speak with the OS:
cordova plugin add org.apache.cordova.geolocation
More: http://docs.phonegap.com/en/3.2.0/cordova_geolocation_geolocation.md.html

Worklight app results in PERSISTENT_STORE_FAILURE with JSONStore on my phone

I just tried a small sample worklight app on my phone to test the JSONStore, the init code for which is as follows in my file jsontest.js.
function wlCommonInit(){
var i;
var collectionName = 'exp';
var options = {};
var collections = {};
//Object that defines the 'people' collection
collections[collectionName] = {};
//Object that defines the Search Fields for the 'people' collection
WL.JSONStore.destroy(options);
collections[collectionName].searchFields = {name: 'string', age: 'integer'};
WL.JSONStore.init(collections, options)
.then(function () {
alert ("JSON Store initialization success!");
})
.fail(function (errorObject) {
alert (errorObject);
});
I'm getting the error -1: PERSISTENT STORE FAILURE when I run the app on my phone (Galaxy Nexus). The following errorObject is returned.
{
"src": "initCollection",
"err": -1,
"msg": "PERSISTENT_STORE_FAILURE",
"col": "exp"
"usr": "jsonstore",
"doc": {},
"res": {}
}
The app works fine in the Worklight console simulator and in the AVD. My phone has enough storage (600 MB left) to run the app so that shouldn't be a problem.
What am I doing wrong here? Does this have anything to do with the fact that I'm running a custom ROM?
UPDATE: I checked the app on my dad's phone (Sony Xperia Sola) and it worked! Very weird. It doesn't run on my phone, even though all other third-party apps that I have downloaded so far on my phone from the Play Store and other sources all work fine.
So, does Worklight not support custom ROMs?
The custom ROM that I am using is VanirAOSP. I applied a popular custom kernel and I'm using the Dalvik runtime (not ART or anything like that).
I also think that the problem might be because Worklight apps are not fully supported on Android 4.4 KitKat.
Would appreciate it if someone would shed some light on this.
There is an issue that affects the JSONstore when using Worklight 6.0 on Android 4.4, which causes the behavior your are seeing. You can get more information about this here:
http://www-01.ibm.com/support/docview.wss?uid=swg27040512
If you are using Worklight Consumer Edition or Worklight Enterprise Edition, you can get a fix for this issue by upgrading to Worklight 6.0.0.2 (a/k/a Worklight 6.0 Fix Pack 2).
If you are using Worklight Developer Edition, you should be able to use the Eclipse "Check for Updates" function to upgrade your Worklight 6.0 Developer Edition installation to Fix Pack 2.
Note that after applying the fix, you must remove the JSONstore feature from your application, and then add it back again; this is described in the APAR document that you can access from the page I've linked above.

Facebook Authentication on android device causes failure of application (Titanium android)

In my application I am using facebook authentication.My code looks like
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
layout:'vertical'
});win1.open();
Titanium.Facebook.appid = "appid";
Titanium.Facebook.permissions = ['abc'];
var facebook_button = Ti.UI.createButton(
{
height:50,
width:200
});win1.add(facebook_button);
facebook_button.addEventListener('click', function(e)
{
Titanium.Facebook.authorize();
});
var facebook = Titanium.Facebook.createLoginButton({
style:'wide',
bottom:80
});
win1.add(facebook);
Titanium.Facebook.addEventListener('login', connect_facebook);
function connect_facebook()
{
alert('inside');
Titanium.Facebook.logout();
}
Now problem occur when I click on facebook_button. When I install application on android device(version 2.2) I click on facebook_button it causes forced close of application. after forced close If I again start application and use same functionality it's working fine.My log records gives following error java.lang.NullPointerException.
if I use titanium facebook button i.e. Ti.Facebook.createLoginButton it's not giving any error even on first use also. But I want to use my own customize log-in button.
I want to remove this null pointer exception. I am using android sdk 2.0.1. and tested on android device 2.2.On simulator application running without any error.Is there any way to solve this problem? need help.. thank you..
I have no experience in connecting to Facebook from Titanium, but installed one of their new example apps two days ago: https://wiki.appcelerator.org/display/guides/Example+Applications#ExampleApplications-ARti
This connects to FB, do not know in what way. You can download example code from GitHub, maybe you find it useful.
Besides, in my experience the older Android SDK versions you are using have some issues. I have better experiences using 2.3 and newer. Recently compiled an app with SDK 4.x and have it running on a device with 2.2, so no problems with backward compatibility. Maybe it helps to upgrade your SDKs.

Categories

Resources