I have managed to put a broadcast receiver from the manifest file, it looks like this:
<receiver android:name=".BReceivers.CallBReciever">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
Now what i am trying to do is to take it out of the manifest and start it only when the user presses a certain button, which should look somethings like this:
Button start = (Button) findViewById(R.id.Button_Start);
start.setOnClickListe开发者_StackOverflow中文版ner(new View.OnClickListener() {
public void onClick(View v) {
@Override
public void onReceive(Context context, Intent arg1) {
Log.d("aaa", "bbb");
switch (getResultCode())
{
}
}
}, new IntentFilter(Intent.ACTION_CALL));
}
}
});
But i don't get into the receiver, any idea why? what IntentFilter String param should i use?
You have to implement phone state listener to listen your call state
for more information refer this
精彩评论