对于许可证检查,如果传递“未许可”响应,但没有或低连接,我一直在尝试解决。我想检查信号强度,如果它超过50%(15)或由于没有连接而返回99,我希望它绕过检查,直到下次以更好的信号启动应用程序。通过这种方式,任何授权用户都不应该看到NOT LICENSED响应。getGsmSignalStrength()总是返回'99'
问题1:使用getGsmSignalStrength()时,只返回phone/3g/4g强度或wifi强度。如果用户使用的是WiFi模式,那么它应该可以工作?我知道如何检查WiFi是否连接,所以如果需要的话,我总是可以使用它来检查WiFi。
问题2:getGsmSignalStrength()总是返回'99'的值,即使当我盯着我的手机,它显示出完整的实力。
ConnecetivityCheck.java的全部目的是检查然后继续。现在我只是自动跳过检查并显示带有getGsmSignalStrength()数字的Toast框,但这总是显示'99'。
请帮助,谢谢。 下面我重视我的代码...
的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>
的java文件
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 */
}
我在美国。 DOH!那么这也可以解释为什么它只会出现99. LOL。谢谢。它总是你看过的小事。你知道CDMA的范围吗? – djmedic 2012-04-24 20:08:47
没有抱歉,但该信息不应该太难找到。祝你好运! – Heinrisch 2012-04-24 20:42:34
CDMA的范围是什么?它总是负的dBm,所以不知道这是如何工作的百分比。 – JPM 2013-01-09 20:49:21