use of android.telephony.PhoneStateListener in project PLDroidPlayer by pili-engineering.
the class PLAudioPlayerActivity method startTelephonyListener.
// Listen to the telephone
private void startTelephonyListener() {
mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (mTelephonyManager == null) {
Log.e(TAG, "Failed to initialize TelephonyManager!!!");
return;
}
mPhoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
// TODO Auto-generated method stub
super.onCallStateChanged(state, incomingNumber);
switch(state) {
case TelephonyManager.CALL_STATE_IDLE:
Log.d(TAG, "PhoneStateListener: CALL_STATE_IDLE");
if (mMediaPlayer != null) {
mMediaPlayer.start();
}
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d(TAG, "PhoneStateListener: CALL_STATE_OFFHOOK");
if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
}
break;
case TelephonyManager.CALL_STATE_RINGING:
Log.d(TAG, "PhoneStateListener: CALL_STATE_RINGING: " + incomingNumber);
break;
}
}
};
try {
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
} catch (Exception e) {
e.printStackTrace();
}
}
use of android.telephony.PhoneStateListener in project android_frameworks_base by ParanoidAndroid.
the class ComprehensiveCountryDetector method addPhoneStateListener.
protected synchronized void addPhoneStateListener() {
if (mPhoneStateListener == null) {
mPhoneStateListener = new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
mCountServiceStateChanges++;
mTotalCountServiceStateChanges++;
if (!isNetworkCountryCodeAvailable()) {
return;
}
if (DEBUG)
Slog.d(TAG, "onServiceStateChanged: " + serviceState.getState());
detectCountry(true, true);
}
};
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
}
use of android.telephony.PhoneStateListener in project platform_frameworks_base by android.
the class ComprehensiveCountryDetector method addPhoneStateListener.
protected synchronized void addPhoneStateListener() {
if (mPhoneStateListener == null) {
mPhoneStateListener = new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
mCountServiceStateChanges++;
mTotalCountServiceStateChanges++;
if (!isNetworkCountryCodeAvailable()) {
return;
}
if (DEBUG)
Slog.d(TAG, "onServiceStateChanged: " + serviceState.getState());
detectCountry(true, true);
}
};
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
}
use of android.telephony.PhoneStateListener in project android_frameworks_base by DirtyUnicorns.
the class ComprehensiveCountryDetector method addPhoneStateListener.
protected synchronized void addPhoneStateListener() {
if (mPhoneStateListener == null) {
mPhoneStateListener = new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
mCountServiceStateChanges++;
mTotalCountServiceStateChanges++;
if (!isNetworkCountryCodeAvailable()) {
return;
}
if (DEBUG)
Slog.d(TAG, "onServiceStateChanged: " + serviceState.getState());
detectCountry(true, true);
}
};
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
}
use of android.telephony.PhoneStateListener in project android_frameworks_base by ResurrectionRemix.
the class ComprehensiveCountryDetector method addPhoneStateListener.
protected synchronized void addPhoneStateListener() {
if (mPhoneStateListener == null) {
mPhoneStateListener = new PhoneStateListener() {
@Override
public void onServiceStateChanged(ServiceState serviceState) {
mCountServiceStateChanges++;
mTotalCountServiceStateChanges++;
if (!isNetworkCountryCodeAvailable()) {
return;
}
if (DEBUG)
Slog.d(TAG, "onServiceStateChanged: " + serviceState.getState());
detectCountry(true, true);
}
};
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_SERVICE_STATE);
}
}
Aggregations