llb988
android监控来电显示
当电话来电的时候,我们要监控着电话号码的来电,哪我们是通过代码控制,下面我们看看利用吐丝显示来电显示
view source print ?
import android.app.Activity; |
import android.content.Context; |
import android.os.Bundle; |
import android.telephony.PhoneStateListener; |
import android.telephony.TelephonyManager; |
import android.widget.Toast; |
public class Main extends Activity { |
public class MyPhoneCallListener extends PhoneStateListener{ |
public void onCallStateChanged( int state, String incomingNumber) { |
case TelephonyManager.CALL_STATE_OFFHOOK: |
Toast.makeText(Main. this , "正在通话中...." , Toast.LENGTH_SHORT).show(); |
case TelephonyManager.CALL_STATE_RINGING: |
Toast.makeText(Main. this , incomingNumber, Toast.LENGTH_SHORT).show(); |
super .onCallStateChanged(state, incomingNumber); |
public void onCreate(Bundle savedInstanceState) { |
super .onCreate(savedInstanceState); |
setContentView(R.layout.main); |
TelephonyManager tm=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); |
MyPhoneCallListener myPhoneCallListener= new MyPhoneCallListener(); |
tm.listen(myPhoneCallListener, PhoneStateListener.LISTEN_CALL_STATE); |
<?xml version= "1.0" encoding= "utf-8" ?> |
<LinearLayout xmlns:android= "http://schemas.android.com/apk/res/android" |
android:orientation= "vertical" |
android:layout_width= "fill_parent" |
android:layout_height= "fill_parent" |
android:id= "@+id/phonestate" |
android:layout_width= "fill_parent" |
android:layout_height= "wrap_content" |
- Android(安卓)Studio 新建编辑条 点击按钮显示控件中的内容
- android 关于listview scrollview 底部 控件无法显示的两个解决
- 关于用Android的API重写drawRegion方法的代码
- Android:adb shell am命令行发送Activity/Service/Broadcast
- Android(安卓)studio使用SVN
- list多选 android,Android(安卓)ExpandableListView单选以及多选
- Android————一个简单记账本(Bookkeeping)
- android之ContentResolver与ContentProvider
- Android(安卓)内核源代码交叉编译(创建自己的模拟器内核,哈哈终于
随机推荐
-
seaborn常用的10种数据分析图表
-
基于geopandas的空间数据分析-深入浅出分
-
火爆全网的动态曲线图是怎么做的?
-
使用pyecharts绘制词云图-淘宝商品评论展
-
使用sklearn轻松实现数据缩放
-
Numpy进阶之排序小技巧
-
8个超好用的Python内置函数,提升效率必备!
-
全平台都能用的pandas运算加速神器
-
现代浏览器探秘(part4):事件处理 [每日前
-
一步步教你用实现HTML5 SVG动画效果 [每