发送广播

2050阅读 0评论2015-11-26 luozhiyong131
分类:Android平台


点击(此处)折叠或打开

  1. package org.lxh.demo;
  2. import android.app.Activity;
  3. import android.content.Intent;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.view.View.OnClickListener;
  7. import android.widget.Button;
  8. public class MyBroadcastDemo extends Activity {
  9.     private Button mybut ;                // 按钮组件
  10.     @Override
  11.     public void onCreate(Bundle savedInstanceState) {
  12.         super.onCreate(savedInstanceState);
  13.         super.setContentView(R.layout.main);            // 设置默认布局管理器
  14.         this.mybut = (Button) super.findViewById(R.id.mybut) ;    // 取得组件
  15.         this.mybut.setOnClickListener(new OnClickListenerImpl());    // 设置监听
  16.     }
  17.     private class OnClickListenerImpl implements OnClickListener {
  18.         @Override
  19.         public void onClick(View v) {
  20.             Intent it = new Intent(Intent.ACTION_EDIT);    // 启动Action
  21.             MyBroadcastDemo.this.sendBroadcast(it);        // 进行广播
  22.         }
  23.     }
  24. }
030908_广播机制:Broadcast.ppt
上一篇:PendingIntent
下一篇:AppWidget