如何处理应用中的信号问题或增强信号

时间:2014-03-31 12:16:41

标签: android

有没有办法处理应用程序锄头增强网络信号中的信号不良问题?像https://play.google.com/store/apps/details?id=com.bosscellular.curtishttps://play.google.com/store/apps/details?id=com.alportela.apptoola.network_booster这样的Playstore中的isee appp但不知道它们如何工作如何以任何人知道的方式提升信号?下面是我的代码,它只返回网络强度但我想提高信号强度我该怎么办?

    private static final int EXCELLENT_LEVEL = 51;
private static final int GOOD_LEVEL = 50;



ProgressBar progressBar;
TextView textView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    progressBar = (ProgressBar) findViewById(R.id.signalLevel);
    textView = (TextView) findViewById(R.id.signalLevelInfo);
Toast.makeText(getApplication(), "Please try again \n Your Connection Signal are Low",      
          Toast.LENGTH_SHORT).show();

    startSignalLevelListener();

}





private void setSignalLevel(int level) {
    int progress = (int) ((((float) level) / 31.0) * 100);
    String signalLevelString = getSignalLevelString(progress);

    progressBar.setProgress(progress);

    textView.setText(signalLevelString);

    Log.i("signalLevel ", "" + progress);
}

private String getSignalLevelString(int level) {
    String signalLevelString = "Weak";

    if (level >= EXCELLENT_LEVEL)
    {
        signalLevelString = "High";
    progressBar.getProgressDrawable().setColorFilter(Color.GREEN, Mode.OVERLAY );
    }

    else if (level <= GOOD_LEVEL)
    {
        signalLevelString = "Weak";
        progressBar.getProgressDrawable().setColorFilter(Color.RED,  Mode.OVERLAY );

    }


    return signalLevelString;
}

private void stopListening() {
    TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

    tm.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
}


private void startSignalLevelListener() {
    TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    int events = PhoneStateListener.LISTEN_SIGNAL_STRENGTH
            | PhoneStateListener.LISTEN_DATA_ACTIVITY |

            PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |

            PhoneStateListener.LISTEN_SERVICE_STATE;

    tm.listen(phoneStateListener, events);
}

private final PhoneStateListener phoneStateListener = new PhoneStateListener() {



    @Override
    public void onSignalStrengthChanged(int asu) {


        setSignalLevel(asu);

        super.onSignalStrengthChanged(asu);
    }
};

0 个答案:

没有答案