package ycitss.testbc2;
import android.app.Activity;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class TestBC2Activity extends Activity {
/** Called when the activity is first created. */
private Button registerButton = null;
private Button unregisterButton = null;
private SMSReceiver smsReceiver = null;
private static final String SMS_ACTION = "android.provider.Telephony.SMS_RECEIVED";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
registerButton = (Button) findViewById(R.id.register);
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 生成一个BroadcastReceiver对象
smsReceiver = new SMSReceiver();
// 生成一个IntentFilter对象
IntentFilter filter = new IntentFilter();
// 为IntentFilter添加一个Action
filter.addAction(SMS_ACTION);
// 将BroadcastReceiver对象注册到系统当中
TestBC2Activity.this.registerReceiver(smsReceiver, filter);
}
});
unregisterButton = (Button) findViewById(R.id.unregister);
unregisterButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 解除BroadcastReceiver对象的注册
TestBC2Activity.this.unregisterReceiver(smsReceiver);
}
});
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
android mars视频代码 Broadcast TestBC2源码 BroadcastReceiver www.mars-droid.com/Android开发视频教程 代码 源码 mars老师讲课 android 视频源码(在此特别感谢mars的无私奉献,此代码为跟随视频边学边做的)
资源推荐
资源详情
资源评论
收起资源包目录
TestBC2.rar (26个子文件)
TestBC2
AndroidManifest.xml 769B
res
layout
main.xml 529B
drawable-ldpi
icon.png 2KB
drawable-mdpi
icon.png 3KB
drawable-hdpi
icon.png 4KB
values
strings.xml 179B
proguard.cfg 1KB
src
ycitss
testbc2
TestBC2Activity.java 1KB
SMSReceiver.java 1KB
bin
TestBC2.apk 15KB
classes.dex 5KB
ycitss
testbc2
TestBC2Activity$2.class 943B
SMSReceiver.class 1KB
R.class 503B
R$layout.class 382B
R$attr.class 328B
TestBC2Activity$1.class 1KB
TestBC2Activity.class 2KB
R$id.class 408B
R$string.class 415B
R$drawable.class 388B
resources.ap_ 11KB
.classpath 280B
assets
default.properties 362B
.project 843B
gen
ycitss
testbc2
R.java 789B
共 26 条
- 1
资源评论
- sxy0508192013-01-11运行不起来啊
mbcqss
- 粉丝: 10
- 资源: 108
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功