What to do if in react-native DeviceMotion is not available? - android

In my react-native app I use DeviceMotion from expo-sensors, when running await DeviceMotion.isAvailableAsync() line it returns false.
In any documentation that I read, it's not said what to do in this case. Is it a limitation of the device itself? Or is there a way to enable it? I couldn't find anything in settings. How do I enable it if it is possible?

Related

Read Preferred Network Type Setting

I am trying to read the Preferred network type setting from the device. But nowhere android API's are available.
Use case:
Trying to read the Preferred network type and connected network type so that if the device has LTE enabled and the user is forcefully switched back to the lower network(3G,2G); then there should be a notification sent to the user.
I have checked the system setting code, But it's deprecated.
Settings.Secure.getString(getApplicationContext().getContentResolver(),
Settings.System.NETWORK_PREFERENCE);
Is there any alternate way to read the system secured settings(By reflection?).
And Also is it possible to write back the setting with the user permission?
Help is much appreciated.
I think the right code is:
Settings.Global.getString(context.getContentResolver(),Settings.Global.NETWORK_PREFERENCE)

Meteor on android device can't get GPS position

I have a mobile application done in Meteor + ionic and I'm trying to get the user GPS location using this simple code:
navigator.geolocation.getCurrentPosition( function ( result ) {
console.log( result );
Session.set( 'pos', result );
}, function ( err ) {
console.log( err );
});
All I get is a warning saying that getCurrentPosition deprecated on insecure locations.
Why is my app seen as an insecure location since I'm running it with meteor run android-device which basically installs it on my phone then runs it like any other app?
If I open up the chrome inspector and control the app's browser I can switch the url from http://meteor.local to https://meteor.local making it a "secure location" but all I get is a timeout error when getCurrentPosition is fired.
So...how does one get the user's position inside a meteor mobile application?
According to the documentation you need to use the cordova geolocation plugin. I believe this is because the webview used by cordova may not have all the features of chrome on your mobile -- which is a natural but wrong assumption.
According to the geolocation plugin readme you need to add the plugin:
meteor add mdg:geolocation.
and then you can use:
Geolocation.currentLocation()
There might be a way to do this all with navigator.geolocation, but if you use the native functionality provided via the plugin then you won't need to worry much about security consideration in browsers. It will also ensure that things will work on older devices that may use a version of the webview that doesn't yet implement the geo API.
I had the same problem when using the navigator.geolocation. It seems like the error function will never be fired because the timeout default value is actually infinity. To solve it is to actually set a minimum timeout value.
navigator.geolocation.getCurrentPosition(success,error,{timeout:5000});

Android : Network info measurement

I am trying to develop android applicaton for getting low-level info about network info measurement.
I want to know How to get these data?
3G:
-RSCP
-ECNO (not Eclo)
-BER
2G:
-RxLevelQuality
-RxLevelSub
Call State:
-Handover
-Dropped Call
-Call Failed
If anyone have idea,Please help me!.
[CALL STATE]
I found 'DisconnectCause' from here
, but I think it always return NORMAL.
You can build your own firmware that collects this information, then deploy this firmware on your personal phone.
Outside of what you get from TelephonyManager, the rest of your requested data is inaccessible by Android SDK applications.
I found 'DisconnectCause' from here , but I think it always return NORMAL.
That is not from the Android OS. That is from SipDroid, a third-party SIP client.

Change network selection mode programmatically

I'm trying (wondering if it's even possible) to write an app, that would change the network selection mode automatically, based on some criteria. E.g. change the network operator from Vodafone to T-Mobile (assuming that the SIM card registration will succeed, but I'm not worried about it atm)
Unfortunately, I can't seem to find any way in the API to do it. Anyone has any idea?
I assume, since it's not in the public APIs, there might still be a way to do it, if the phone is rooted. Is that true? If so, where should I look?
Thanks in advance
Sorry but you can't.
You can have a look into the TelephonyManager .
You can know the current operator: getSimOperator(Name) / getNetworkOperator(Name).
You can also check this thread saying "I learn that for the sake of security there aren't any public APIs to manage this so the only option is to send the user to the system PreferenceScreen within my app."
How about using android.telephony.CarrierConfigManager? I read about it on https://developer.android.com/reference/android/telephony/CarrierConfigManager.html and it seems to allow you to change alot of carrier-specific parameters, although the app must be signed with the certificate that has a matching signature to one on the SIM, so it can usually only be implemented by the carrier issuing the SIM. See also https://source.android.com/devices/tech/config/carrier.
I havent found an actual method to actively switch carrier, but if anywhere, I'd expect it to be there.

Settings management from code

I just want to ask you if you anyone knows how to change the Setting
available in:
Settings->Wireless Settings->Mobile Network from code or
Setting: Settings->Wireless Settings->Mobile Network Settings->Network
operators->Select Automatically?
I had been unable to find a property that match this setting in the
Settings.System / Settings.Secure classes.
Is there any alternative way to "turn on/off" the MOBILE
connectivity ?
The reason I need to solve this is to workaround the
bug occur during transitioning from WIFI to MOBILE that do not enable
CELL data automatically.
I think support for this sort of thing(changing settings from code) was removed/deprecated in the newer versions of the SDK; it is not advisable. What I've said is based on Dan Morill's Blog titled: Future Proofing your Android Apps
Eitherways, generally, you would write:
Settings.System.putString(getContentResolver(), <Settings.System.CONST>, <value>);
and have the following permission in your maifest: android.permission.WRITE_SETTINGS
The List of Settings.System.CONST can be found in the official documentation: see here

Categories

Resources