In my app, I'm checking the geolocalization state with this test
--> I need the user to have Wifi and GPS Enabled-
public boolean enableGPSifDown() {
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
return true;
The thing is in the cel (Android 4.2.2), all the GPS checkbox are cheked and wifi is on, nevertheless, this method always return false.
I've been using this method for all kind of cells ( Samsung, motorola, alcatel, sony, etc...) and never had problem with that, but with this "verykool" phone, it gives me false???
I have the permission :
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Any idea other than change the phone????
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'm trying to dial a number and when the call connects turn ON the speaker.
I've already read lots of topics that achieve this problem, but cannot get it working.
This is what I have.
Toast.makeText(getApplicationContext(), "CALL_STATE_OFFHOOK",
Toast.LENGTH_LONG).show();
Context context = (Context)getApplicationContext();
AudioManager audioManager2 = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
audioManager2.setMode(AudioManager.MODE_IN_CALL);
audioManager2.setSpeakerphoneOn(true);
The listener is working fine. I can see the toast "CALL_STATE_OFFHOOK" when the call is established, but the rest of the code is not working.
Am I missing something ?
Thanks !
UPDATE
This are my permissions
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
UPDATE 2
Actually calling:
audioManager2.isSpeakerphoneOn()
returns false before
audioManager2.setSpeakerphoneOn(true);
and
audioManager2.isSpeakerphoneOn()
returns true after
audioManager2.setSpeakerphoneOn(true);
but the speaker really did not turn ON.
Did you set the option "AUDIO_SETTINGS" on true in your manifest?
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" />
When I used the code bellow in my phone it always selects the network to get Longitude and Latitude and didn't select the GPS even when the Wi-Fi is off. I want the application to choose the best, running, accurate location provider.
LocationManager LM1=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider=LM1.getBestProvider(criteria, true);
LM1.requestLocationUpdates(provider,500,1,this);
ET3.setText(provider);
the permissions used are:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
If you want the most accurate, check if GPS is enabled. If it is, use it. If not, use network. Sending a blank criteria to getBestProvider will never cause you to use GPS- its going to assume you don't need that accuracy.
I'm trying to get the neighbouring cell info in Android but the function getNeighboringCellInfo() always return null.
I used the following code :
protected void getCellInfo() {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
List<NeighboringCellInfo> neighborCells = telephonyManager.getNeighboringCellInfo();
if (neighborCells == null) {
OutUtils.debug("no neighbor cells");
} else {
...
}
}
The context variable is from a Service class.
My AndroidManifest.xml permission
<uses-permission android:name="android.permission.INTERNET"/>
<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.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I tried with and without enabling the "Use 2G networks" option in Android.
Any idea ? Thanks
If you can run logcat, try running logcat -b radio. If you are lucky, the RIL code will be spitting out debug messages, showing the actual request to the modem for the neighboring cell info. It could well be that the modem is just returning an empty list. If this is the case, it has nothing to do with permissions, and there is not much you can to fix it.
The cellid implementation varies from mobile device to mobile device since these features are considered to be optional. for example:
Samsung (all devices): getNeigbouringCells () is not supported at all and always returns an empty list.
according to this: http://wiki.opencellid.org/wiki/Android_library
and this: https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=24306
I think, maybe you haven't set all necessary permissions in Manifest. look here Null Issue with NeighboringCellInfo, CID and LAC
If you think you have them, put the manifest in the question, too, please.