В книге Голощапова нашёл пример BroadcastReceiver-а, который отлавливает исходящий звонок и выводит Toast. Вот код:
Код: Выделить всё
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class OutgoingCallReceiver extends BroadcastReceiver{
public static final String TAG = "BroadcastReceiver";
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)){
try{
Toast.makeText(context, "Исходящий звонок!!!", Toast.LENGTH_LONG).show();
Log.e(TAG,"Исходящий звонок ");
}catch(Exception e){
Log.e(TAG,"Ошибка исходящий звонок ->" + e);
}
}
}
}
Код: Выделить всё
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tyapavel.outgoingcall"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<application android:label="@string/app_name"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme">
<receiver
android:name="OutgoingCallReceiver">
<intent-filter >
<action
android:name="android.intent.action.NEW_OUTGOING_CALL">
</action>
</intent-filter>
</receiver>
</application>
</manifest>