Read Phone State Reciever not working on real device

I have tested my reciever on emulator and simulate face call to emulator and can log phone state even get calling number, However if i try this on real device, it is not working. I added an activity and if it working background, it works. But why should i add it? Why has to activity run on background?

public void onReceive(Context cnx, Intent nt) {
    Bundle bnd = nt.getExtras();
    Log.e("EXTRA", "EXTRA");
    if (bnd != null) {
        String state = bnd.getString(TelephonyManager.EXTRA_STATE);
        Log.i("PHONE STATE", state);

        if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
            Log.i("PHONE STATE",



Activity meant to be run in Foreground, If you want to run your process in Background you should use Services. read here more

For your question, You should have separate class for receiver, Register receiver in Manifest file for Phone state change action and with permission to read phone state.

Need Your Help

Wordpress Blog page a:visited and category tags invisible 'white'

css wordpress class blogs

I've built a wordpress theme from scratch however style the bootstrap navigation to white text and brown text on selection - this appears to be overiding the a: visit and a: hover on everything i've

What is an .axd file?


What kind of purpose do .axd files serve?