Do to the Licensing check delivering a "Not Licensed" response with no or low connection, I have been trying a work around. I wanted to check the signal strength and if it is over 50% (15) or returns a 99 because of no connection, I want it to bypass the check until the next time the app is started with a better signal. This way no authorized user should ever see the NOT LICENSED response.
Question 1: When using getGsmSignalStrength() does only return phone/3g/4g strength or wifi strength as well. If the user is in wifi mode than it should work as well? I do know how to check to see if wifi is connected, so I can always use that to check wifi if needed.
Question 2: getGsmSignalStrength() is always returning a value of '99' even when I am staring at my phone and it is showing full strength.
The entire purpose of ConnecetivityCheck.java is check then continue. Right now I just have it automatically jumping over the check and showing Toast box with the getGsmSignalStrength() number, but this is always showing '99'.
Please Help, thank you. Below I have attached my code...
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.emsprotocols.ilpaemsprotocols"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<!-- PERMISSIONS -->
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- LICENSE PERMISSIONS -->
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<!-- USES -->
<uses-feature android:name="android.hardware.telephony" android:required="false"/>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true">
<activity android:name=".ProtocolsSplashActivity"
android:label="@string/app_name">
<intent-filter>
The .Java file
package com.emsprotocols.ilpaemsprotocols;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.PhoneStateListener;
import android.telephony.SignalStrength;
import android.telephony.TelephonyManager;
import android.widget.Toast;
public class ConnectivityCheck extends Activity {
TelephonyManager Tel;
MyPhoneStateListener MyListener;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
/* Update the listener, and start it */
MyListener = new MyPhoneStateListener();
Tel = ( TelephonyManager )getSystemService(Context.TELEPHONY_SERVICE);
Tel.listen(MyListener ,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
startActivity(new Intent(this, ProtocolsMMenuActivity.class));
ConnectivityCheck.this.finish();
}
/* Called when the application is minimized */
@Override
protected void onPause()
{
super.onPause();
Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE);
}
/* Called when the application resumes */
@Override
protected void onResume()
{
super.onResume();
Tel.listen(MyListener,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
/* —————————– */
/* Start the PhoneState listener */
/* —————————– */
private class MyPhoneStateListener extends PhoneStateListener
{
/* Get the Signal strength from the provider, each tiome there is an update */
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength)
{
int strengthAmplitude = signalStrength.getGsmSignalStrength();
super.onSignalStrengthsChanged(signalStrength);
Toast.makeText(getApplicationContext(), "GSM Cinr = "
+ String.valueOf(strengthAmplitude), Toast.LENGTH_SHORT).show();
}
};/* End of private Class */
}
Question 1: It should only be GSM signal strength.
Question 2: I can't find anything wrong with your code, are you sure that you have a GSM signal? If you live in the US is more likely that you are using a CDMA network. There are other ways to get that signal strength: Link