PhoneReceiver.java
Dosyayı İndir
package com.godoro.androiddevices;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
public class PhoneReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Telefon olayı algılandı",Toast.LENGTH_SHORT).show();
Log.w("GodoroAndroid", "Telefon olayı algılandı");
if (intent.getExtras() == null) {
return;
}
String phoneState = intent.getExtras().getString(
TelephonyManager.EXTRA_STATE);
String phoneNumber = intent.getExtras().getString(
TelephonyManager.EXTRA_INCOMING_NUMBER);
if (phoneState.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
Toast.makeText(context, "Telefon çalması algılandı " + phoneNumber,Toast.LENGTH_SHORT).show();
Log.w("GodoroAndroid", "Telefon çalması algılandı " + phoneNumber);
} else if (phoneState.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
Toast.makeText(context, "Telefon açılması algılandı",Toast.LENGTH_SHORT).show();
Log.w("GodoroAndroid", "Telefon açılması algılandı " );
}
}
}
Dosyayı İndir