获取手机信号强度
来源:互联网 发布:mac如何连续选中 编辑:程序博客网 时间:2024/06/11 23:41
要想获取信号强度,需要加入权限:
<uses -permission android:name="android.permission.CHANGE_NETWORK_STATE"></uses>
AndroidManifest.xml
< ?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Firstdroid.Tutorial.GetGsmSignalStrength" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".GetGsmSignalStrength" android:label="@string/app_name"> <intent -filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent> </activity> </application> <uses -sdk android:minSdkVersion="4" /> <uses -permission android:name="android.permission.CHANGE_NETWORK_STATE"></uses> </manifest>
import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.telephony.PhoneStateListener; import android.telephony.SignalStrength; import android.telephony.TelephonyManager; import android.widget.Toast;public class GetGsmSignalStrength extends Activity { /* This variables need to be global, so we can used them onResume and onPause method to stop the listener */ TelephonyManager Tel; MyPhoneStateListener MyListener; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* Update the listener, and start it */ MyListener = new MyPhoneStateListener(); Tel = ( TelephonyManager )getSystemService(Context.TELEPHONY_SERVICE); Tel.listen(MyListener ,PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); } /* 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 从得到的信号强度,每个tiome供应商有更新*/ @Override public void onSignalStrengthsChanged(SignalStrength signalStrength) { super.onSignalStrengthsChanged(signalStrength); Toast.makeText(getApplicationContext(), "Go to Firstdroid!!! GSM Cinr = " + String.valueOf(signalStrength.getGsmSignalStrength()), Toast.LENGTH_SHORT).show(); } };/* End of private Class */ }/* GetGsmSignalStrength */
- 获取手机信号强度
- android-获取手机信号强度
- Android监听获取手机信号强度
- Android监听获取手机信号强度
- android-获取手机信号强度(2)
- 手机信号强度
- 手机信号强度
- 手机信号强度
- Android获取到手机信号强度信息后传回给unity
- Android手机信号强度详解
- android手机信号强度
- Android手机信号强度介绍
- Android 手机信号强度
- 手机信号强度流程
- android手机信号强度
- 手机信号强度大小的意义
- 定量分析基站和手机信号强度(辐射)对比
- 关于手机信号强度单位db和dBm
- 关于maven package打包找不到tools.jar的解决方案
- [Android]MirrorOp-Sender传屏端,完全破解版,无5分钟时间限制,无注册窗口
- 第一章 MQ基础概念和介绍
- POSIX消息队列 发送接收简单子
- 如何把iOS 应用移植到Android?
- 获取手机信号强度
- 三种嵌入式操作系统的分析与比析
- Virtualbox访问USB子系统失败的解决方法
- 61
- 给数组赋初值
- 《黑天鹅》natilie portman演的太好了
- 友善之臂视频监控方案源码学习(3) - 守护进程
- JavaScript初探之一_HelloWorld
- ViewPager实现移折通左右滑动引导界面