I am building a simple app in Unity/Tango platform.
I am trying to get the location.
I followed the steps in this https://docs.unity3d.com/ScriptReference/LocationService.Start.html
So after 20 seconds wait it 'Timed out' and the Status is always 'initializing'.
The Input.location.lastData.latitude and Input.location.lastData.longitude is always zero.
In addition I have set this in the AndroidManifest.xml file:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" android:required="true" />
<uses-feature android:name="android.hardware.location" android:required="true" />
Any help would be appreciated.
-Thanks
Found the answer:
On Android devices, LocationService doesn’t work without setting “high accuracy” location mode in the system settings (“Settings” -> “Location” -> “Mode”).
Reference:
https://issuetracker.unity3d.com/issues/android-locationservice-doesnt-work-without-high-accuracy-mode
Related
I am using the CrossGeeks Geofence plugin found here:
https://github.com/CrossGeeks/GeofencePlugin
Using the documentation on the home page and the sample found here to build a test app:
https://github.com/domaven/xamarin-plugins/tree/master/Samples/Geofence
I encounter this error when I try to start monitoring a region:
{System.NullReferenceException: Object reference not set to an instance of an object.
at Plugin.Geofence.GeofenceImplementation.RequestMonitoringStart () [0x00000] in <793ebe419a94494388f459127f8240ff>:0
at Plugin.Geofence.GeofenceImplementation.StartMonitoring (Plugin.Geofence.GeofenceCircularRegion region) [0x00061] in <793ebe419a94494388f459127f8240ff>:0
at GeoFenceApp.MainPageViewModel.StartStopMonitoring () [0x00027] in C:\Users\ctodd\source\repos\GeoFenceApp\GeoFenceApp\MainPageViewModel.cs:87 }
The CrossGeofence object itself is not null and neither is the _myRegion object:
screenshot of cross geofence object
screenshot of region object
I believe I am initialising things correctly according to the documentation and the sample.
I'm using the following permissions, even though I believe only fine_location, coarse_location, read_gservices and boot_completed are necessary:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
A google api key is necessary in the sample because a map is being displayed, but I don't need to display a map. Do I still need this key to access location services?
After the permissions, I'm really not sure what is causing the error, as I've tried to follow the documentation.
I have the following permissions explicitly requested in my manifest.
I would like to optimize store visibility by switching as many as possible of them to implicit 'uses-feature' declarations. I will also handle this additionally in code checking for features before I access them.
Internet access is the only thing that's truly required for my app, other features I can enable/disable conditionally based on hasFeatures().
Question:
Which of these permissions can I change?
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="com.android.vending.BILLING" />
<permission android:name="com.appName.supportmapfragment.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.appName.supportmapfragment.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Set required to 'false' if your app doesn't require something to run:
To control filtering, always explicitly declare hardware features in
elements, rather than relying on Google Play to
"discover" the requirements in elements. Then, if
you want to disable filtering for a particular feature, you can add a
android:required="false" attribute to the declaration.
http://developer.android.com/guide/topics/manifest/uses-permission-element.html (in the right-hand sidebar)
The documentation has this example:
<uses-feature android:name="android.hardware.camera" android:required="false" />
I have followed all steps mentioned in the porting guide for V1.
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<meta-data
android:name="com.here.android.maps.appid"
android:value="id here" />
<meta-data
android:name="com.here.android.maps.apptoken"
android:value="token here" />
<uses-library
android:name="com.google.android.maps"
android:required="false" />
<uses-library
android:name="com.here.android"
android:required="false" />
<activity
android:name=".ui.maps.HereLocationsActivity"
android:launchMode="singleTop"
android:hardwareAccelerated="true"
android:theme="#android:style/Theme.Holo"
android:screenOrientation="portrait" >
</activity>
I have added hardwareAcceleration to application tag as well.
It shows location markers properly without map tiles.
What could be the issuw. I am testing on a Nokia X device without SD card.
Any help would be appreciated.
the minSdkVersion should be also changed to be 11, you do need to set the Id & token to values reserved for you
As well as do add following permissions as well:
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.ACCESS_WIFI_STATE
Also do try zooming out, could indeed be that you are located in a area which is shown in white and having full zoom there..
Basically it should be black if the initialization fails, and it should be blue if there is no tiles (or you are at sea), white background thus would indeed be inddicating something else going wrong.
Do also make sure you have enabled location, and have working mobile internet. Would also suggest opening HERE maps app, and downlaoding the maps tiles for the same location used in the app, thus you could see that how it is supposed to look like.
what i am doing::
I have disabled the datapackets so i don't have a internet connection
at the moment in emulator
Now i am checking whether the internet connection is available if not
availabe i am using this code below to launch the screen so that i
can enable the datapackets
code::startActivity(new Intent(WifiManager.ACTION_PICK_WIFI_NETWORK));
This code takes me to page::
When i click on button it shows turning wifion.... but it is not switching on no matter how long i wait
But when i close the app and go to settings manually. I can turn it on
The permissions i have used are below::
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
What is that i am doing wrong here ? how can i correct myself !
try this code.it might helps you
Intent gpsOptionsIntent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
startActivityForResult(gpsOptionsIntent,0);
if you are using wifiManager than you will need this permission.
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
I was just wondering how to request permissions when creating an android application. I am a beginner, so please explain in simple terms :D.
So I want to make it so that my app can vibrate the phone at certain times, and the permission is called "android.permission.VIBRATE." But how do I request this? I do it in the Android Manifest file right?
Thanks for all help!
You're definately right. You need to put it in the AndroidManifest.XML
If you're using eclipse you can do it quite easily and without XML by opening up AndroidManifext.xml and use the Permissions tab at the bottom and press the "Add" button and selecting "Uses Permission" Then just select vibrate from the dropdown list.
If you want to do it in XML code you can add it before the application tag, like so:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:name="Application" >
(the rest of your manifest continues from here)
Also, please accept answers if you found them useful. With a 0% acceptance rate, people won't want to answer your questions.