activity_main.xml:

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context="www.hui2wulian.com.ipph.MainActivity">

android:layout_centerHorizontal="true"

android:layout_centerVertical="true"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:onClick="send"

android:text="电台发送自定义广播"/>


activity_mybrocrec.xml:

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/activity_mybrocrec"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context="www.hui2wulian.com.ipph.MyBrocRec">


activity_outcallreceiver.xml:

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/activity_outcallreceiver"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context="www.hui2wulian.com.ipph.OutCallReceiver">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="outcallreceive"/>


MainActivity.java

packagewww.hui2wulian.com.ipph;

importandroid.content.Intent;

importandroid.support.v7.app.AppCompatActivity;

importandroid.os.Bundle;

importandroid.view.View;

public classMainActivityextendsAppCompatActivity {

@Override

protected voidonCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

public voidsend(View v){

Intent intent=newIntent();

intent.setAction("www.itcast.cn");

sendBroadcast(intent);

}

}


OutCallReceiver.java

packagewww.hui2wulian.com.ipph;

importandroid.content.BroadcastReceiver;

importandroid.content.Context;

importandroid.content.Intent;

/**

* Created by sunzhihui on 2017/6/19.

*/

public classOutCallReceiverextendsBroadcastReceiver {

@Override

public voidonReceive(Context context,Intent intent) {

String outcallnumber=getResultData();

setResultData("100"+outcallnumber);

//        Log.d("OutCallReceiver","收到广播");

//        Log.d("OutCallReceiver","收到广播");

}

}


MyBrocRec.java

packagewww.hui2wulian.com.ipph;

importandroid.content.BroadcastReceiver;

importandroid.content.Context;

importandroid.content.Intent;

importandroid.util.Log;

/**

* Created by sunzhihui on 2017/6/19.

*/

public classMyBrocRecextendsBroadcastReceiver{

@Override

public voidonReceive(Context context,Intent intent) {

Log.d("MyBroadcastReceiver","接收到了广播事件");

Log.d("MyBroadcastReceiver",intent.getAction());

}

}


//

更多相关文章

  1. Android外接扫码枪监听普通输入事件
  2. android js 互动事件
  3. android 禁止系统软键盘,拦截键盘事件
  4. android捕获ListView中每个item点击事件
  5. 防止Android点击按钮过快造成多次事件实现原理
  6. android onFling 事件没有用
  7. Android之键盘点击事件
  8. android事件分发机制一

随机推荐

  1. Android调试笔记——Installation error
  2. android进度对话框的使用
  3. 2.5.6 使用progressDialog创建进度对话框
  4. Android(安卓)com.android.support 版本
  5. Android第二十六课 调试模式 file.exits
  6. android一些不常用的事件
  7. android自定义title
  8. Android(安卓)ndk-stack tool
  9. Android(安卓)网络链接,不要忘记添加网络
  10. Android动画