package com.android.guangbo;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class GuangboActivity extends Activity {
/** Called when the activity is first created. */
public TextView text;
private static final String TAG = "sell";
private BroadcastReceiver receiver = new BroadcastReceiver(){
public void onReceive(final Context context, final Intent intent) {
// Do your action here 用于接收满足条件的 Broadcast
Log.v("fuwuService", "zhunbeizhuce");
String action = intent.getAction();
Log.d(TAG, "1111111111");
if(action.equals(intent.ACTION_SCREEN_ON))
{
Log.d(TAG, "2222222222");
Log.v("fuwuService", "quxiaozhuce");
text.setText("on");
//Intent ceshiintent = new Intent(context,ceshi.class);
Intent ceshiintent = new Intent();
ceshiintent.setClass(context, ceshi.class);
// context.startActivity(ceshiintent);
startActivity(ceshiintent);
}
else if(action.equals(intent.ACTION_SCREEN_OFF))
{
Log.d(TAG, "33333333");
Log.v("fuwuService", "zhixingshijian");
text.setText("of");
}
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button Button1 = (Button) findViewById(R.id.button1);
final Button Button2 = (Button) findViewById(R.id.button2);
text = (TextView) findViewById(R.id.txt);
Button1.setOnClickListener(new OnClickListener() { // 实现行为功能
public void onClick(View v) {
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
Log.d(TAG, "44444444");
registerReceiver(receiver, filter);
Log.d(TAG, "5555555");
}
});
Button2.setOnClickListener(new OnClickListener() { // 实现行为功能
public void onClick(View v) {
Log.d(TAG, "66666666");
unregisterReceiver(receiver);
Log.d(TAG, "77777777");
}
});
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
guangbo.zip_安卓广播
共31个文件
class:11个
png:6个
xml:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 8 浏览量
2022-09-21
17:18:07
上传
评论
收藏 60KB ZIP 举报
温馨提示
移动手机开发,在安卓系统下,实现广播消息,系统应用可以接收到广播的消息。
资源推荐
资源详情
资源评论
收起资源包目录
guangbo.zip (31个子文件)
guangbo
bin
classes.dex 5KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
classes
com
android
guangbo
R$layout.class 429B
R$id.class 479B
R$drawable.class 410B
GuangboActivity.class 2KB
GuangboActivity$2.class 1KB
R$attr.class 343B
R.class 538B
GuangboActivity$1.class 2KB
R$string.class 430B
ceshi.class 498B
GuangboActivity$3.class 1KB
resources.ap_ 11KB
guangbo.apk 16KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
values
strings.xml 180B
drawable-mdpi
ic_launcher.png 3KB
layout
ceshixml.xml 488B
main.xml 898B
assets
gen
com
android
guangbo
R.java 955B
proguard.cfg 1KB
src
com
android
guangbo
GuangboActivity.java 3KB
ceshi.java 281B
.project 843B
.classpath 364B
project.properties 361B
AndroidManifest.xml 739B
共 31 条
- 1
资源评论
JaniceLu
- 粉丝: 85
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功