首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

播音发送与接收的简单实现

2012-09-14 
广播发送与接收的简单实现a.java????Intent intent new Intent(android.intent.action.xxx)??????? ?

广播发送与接收的简单实现

a.java

?

???Intent intent = new Intent("android.intent.action.xxx");
??????? ?sendBroadcast(intent);

?

?

?

b.java

?

xxxx(){

??...

??IntentFilter filter = new IntentFilter();
???????
??????? filter.addAction("android.intent.action.xxx");

??????? mContext.registerReceiver(mIntentReceiver, filter);

}

?

?private BroadcastReceiver mIntentReceiver = new BroadcastReceiver()
?{
??????? @Override
??????? public void onReceive(Context context, Intent intent)
??????? {
??????????? String action = intent.getAction();

??????????? Log.i(TAG,"onReceive action: "+action);
????????????
??????????? if (action.equals("android.intent.action.xxx"))
??????????? {

????????????? ...
??????????? }
?
??????? }


??};

热点排行