我想知道是否有一个代码可以检测我是否正在使用默认的Android手机应用程序调用某人。 这是我的代码,当然我需要更多提示
if(intent.getAction().equals("android.intent.action.PHONE_STATE")){
String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if(intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
call = true;
Log.v("OUTGOING", String.valueOf(call));
//Do-NOTHING
} else {
if (state.equals(TelephonyManager.EXTRA_STATE_IDLE)){
if (call == false) {
Log.v("OUTGOING", String.valueOf(call));
Log.v("CALL", "Call from " + numberPhone);
numberPhone = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
}
}
}
}
答案 0 :(得分:0)
[![Sample_Output][1]][1]
Industry Ship_Date Serial_No Alloy Scap_Value_per_lb
Material Processing 17-Oct-16 4:47:00 PM S472091 C182 NULL
Material Processing 17-Oct-16 4:47:00 PM S472210 C182 NULL
Material Processing 17-Oct-16 4:47:00 PM S472211 C182 NULL
Electronics 17-Oct-16 4:27:00 PM S436738 C180 NULL
Electronics 17-Oct-16 4:27:00 PM S463290 C180 NULL
Electronics 17-Oct-16 4:27:00 PM S463315 C180 NULL
Electronics 17-Oct-16 4:27:00 PM S463327 C180 NULL
Electronics 17-Oct-16 4:27:00 PM S463333 C180 NULL
Electronics 17-Oct-16 4:27:00 PM S463345 C180 NULL
Electronics 17-Oct-16 4:27:00 PM S463354 C180 NULL
并设置接收器
public class OutgoingReceiver extends BroadcastReceiver {
public OutgoingReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Toast.makeText(ctx,
"Outgoing: "+number,
Toast.LENGTH_LONG).show();
}
添加权限
<receiver android:name=".OutgoingCallReceiver" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
你必须注册意图
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>