我是android平台新手。请帮助我了解广播接收器和Intent Filter在android中的行为。
除了
public class OutGoingBrodcast extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
System.err.println("OUTGOING");
Intent i=new Intent();
i.setAction("com.ith.OUT");
context.sendBroadcast(i);
}
}
接收广播
public class IncomingBroadcast extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
if(intent.getAction().equals("com.ith.OUT")){
System.out.println("hit INCOMING");
}
}
}
mainfest
<receiver android:name=".OutgoingReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.SCREEN_OFF"></action>
</intent-filter>
</receiver>
<receiver android:name=".IncomingReceiver" android:enabled="true">
<intent-filter>
<action android:name="com.ith.OUT"></action>
</intent-filter>
</receiver>
我想知道除了
之外还有其他任何方式进行广播Intent i=new Intent();
i.setAction("com.ith.OUT");
context.sendBroadcast(i);
使用com.ith.OUT