Je veux obtenir les forces actuelles du signal dans l'appareil Android sur n'importe quel clic de bouton.
J'ai écrit ce codeobtenir la force du signal android
public static int getSignal(Context c) {
class MyPhoneStateListener extends PhoneStateListener {
int signal;
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
signal = signalStrength.getGsmSignalStrength();
}
}
TelephonyManager Tel;
MyPhoneStateListener MyListener;
MyListener = new MyPhoneStateListener();
Tel = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
Tel.listen(MyListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
Tel.listen(MyListener, PhoneStateListener.LISTEN_NONE);
return MyListener.signal;
}
mais il me renvoie toujours 0
S'il vous plaît quelqu'un me dire comment obtenir forces de signaux actuels.
Il n'y a aucun moyen d'obtenir la puissance actuelle du signal en ce moment? Que faire si je ne veux pas attendre une durée indéterminée pour attendre que le onSignalStrengthsChanged() fasse quelque chose? –
Pls si vous trouvez la solution dites-moi? – Piraba
Hmm - comme détaillé [ici] (http://stackoverflow.com/a/3889407/281545) 'après l'enregistrement de PhoneStateListener vous aurez une notification instantanée'. Toujours votre réponse [devrait être valide] (http://stackoverflow.com/questions/3888775/instant-signal-strength/3889407#comment4143475_3890419) –