我将电话应用程序设置为默认应用程序,并且还在 onCallAdded()方法中获得呼叫。但是在接听电话时,应打开android手机拨号程序,而不是我的默认拨号程序,如truecaller或easycallbalcklist
服务等级
public class TestConnectionService extends InCallService {
@Override
public void onCallAdded(Call call) {
super.onCallAdded(call);
Log.d("callservice","call came");
}
}
MainActivity类
public class MainActivity extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, getPackageName());
startActivity(intent);
}
}
mainfest.xml
<service
android:name=".service.TestConnectionService"
android:permission="android.permission.BIND_INCALL_SERVICE">
<meta-data
android:name="android.telecom.IN_CALL_SERVICE_UI"
android:value="true" />
<intent-filter>
<action android:name="android.telecom.InCallService" />
</intent-filter>
</service>