CallReceiver.java :  » UnTagged » droidtalk » com » googlecode » talkmyphone » Android Open Source

Android Open Source » UnTagged » droidtalk 
droidtalk » com » googlecode » talkmyphone » CallReceiver.java
package com.googlecode.talkmyphone;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;

public class CallReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        SharedPreferences prefs = context.getSharedPreferences("TalkMyPhone", 0);
        boolean notifyIncomingCalls = prefs.getBoolean("notifyIncomingCalls", false);

        if (notifyIncomingCalls) {
            PhoneCallListener phoneListener = new PhoneCallListener();
            TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            telephony.listen(phoneListener, PhoneStateListener.LISTEN_CALL_STATE);
        }
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.