Can not retrieve geolocation in Mobile Application

Discussions regarding 1C:Enterprise for mobile devices with Android, iOS, or Windows Phone.

#1
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Oct 14, 2019
Company: 1c Vietnam

Hi every one,

I meet a problem when get geolocation in mobile application.

I created an app for check-in a task. When I debug in 1C:Enterprise Mobile Platform It works perfectly but when I created an application(I created an *.APK file by using "Application Collector For Mobile Device") It isn't works. So, what is the problem in this case.

Thank you in advance.

Duc Tien NGUYEN  

Here is my function to get Geolocation:

Quote
Function DefineCurrentGeocoordinates() Export

#If MobileAppClient Then
Message("Da vao");
CurrentProvider = "gps";
Try
DM = LocationTools.GetLastLocation(CurrentProvider);
Except
DM = Undefined;
EndTry;

If DM = Undefined Then
CurrentProvider = "network";
Try
DM = LocationTools.GetLastLocation(CurrentProvider);
Except
DM = Undefined;
EndTry;
EndIf;

If DM = Undefined Then
Return Undefined;
EndIf;

If CurrentDate() - ToLocalTime(DM.Date) > 100 Then

LocationTools.UpdateLocation(CurrentProvider, 5);
DM = LocationTools.GetLastLocation(CurrentProvider);

EndIf;

YES = GetAddressByLocation(DM.Coordinates);
If YES = Undefined Then
CurrentLocation =  "Lat: " + DM.Coordinates.Latitude + ", Lon: " + DM.Coordinates.Longitude;
Иначе
CurrentLocation = СтрЗаменить(YES.Presentation, Chars.LF, ", ");

EndIf;

CurrentLocation = CurrentLocation + "Date: " + ToLocalTime(DM.Date) + ", Provider: " + CurrentProvider;

Возврат DM.Coordinates;

#Else

Return Undefined;

#EndIf

EndFunction

 
#2
People who like this:0Yes/0No
Administrator
Rating: 23
Joined: Oct 3, 2019
Company:

Hi Duc Tien NGUYEN!

To work with GPS, the 1C mobile application (if it's made as a standalone .apk file) must have a special key Google API.

You can get this key in the Google developers console: https://console.developers.google.com/project.

How to get the API key is described here: https://developers.google.com/maps/documentation/android-sdk/get-api-key

You need to enable "Maps SDK for Android" API - this will allow your Android (or 1C) application to use the map service from Google.

Then the received API key must be placed in the "Application Collector For Mobile Device" (please see the screenshots) and again make the .apk file.

Download 1.png (42.54 KB)
Download 2.png (29.49 KB)
 
#3
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Jul 10, 2017
Company:

Hm, really? I use GPS data without key...
I always think that key need for use maps API.
But i'll try with key, that may help with "cold start"?

I think you  need see for other reasons:
1. Android version. On some terminals the are old version lower 6.0.
Here you cant use functions if not  include them to manifest.
2. See manifest options in 1C.
3. GPS data may be deactivated on device or only for you app by user. (New security police on Android above 6.1)

 
#4
People who like this:0Yes/0No
Administrator
Rating: 23
Joined: Oct 3, 2019
Company:

Hi Denis!

Using a Google key is an official recommendation from 1C.
I think this is necessary for the command of the type "GetAddressByLocation" to work correctly.

Topikstarter writes that he has the correct application running inside the 1C mobile platform, but it doesn’t work when he creates a standalone .apk file.

According to these signs, it seems that the matter is the lack of a Google key ...

Perhaps your recommendations will also help topikstarter. :-)

In any case, thank you for your help.

Aleksandr

 
#5
People who like this:0Yes/0No
Administrator
Rating: 23
Joined: Oct 3, 2019
Company:

Hi Duc Tien,

could you get the geolocation?

 
#6
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Oct 14, 2019
Company: 1c Vietnam

Hi Aleksandr Biryukov,

I found that the function geo-location isn't work with Android Device with Mobile Platform ver 8.3.15.62. With old version 8.3.9. It Work correctly. An error from platform?

Duc Tien

 
#7
People who like this:0Yes/0No
Active user
Rating: 2
Joined: Oct 14, 2019
Company: 1c Vietnam

Quote
Denis  LSD wrote:
Hm, really? I use GPS data without key...
I always think that key need for use maps API.
But i'll try with key, that may help with "cold start"?

I think you  need see for other reasons:
1. Android version. On some terminals the are old version lower 6.0.
Here you cant use functions if not  include them to manifest.
2. See manifest options in 1C.
3. GPS data may be deactivated on device or only for you app by user. (New security police on Android above 6.1)

Hi Denis,
What is the version of mobile platform that you used?

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.