2017-03-26 10 views
1

ネイティブのAndroid着信UIを使用しようとしています。私はconnectionServiceを持っており、電話アカウントを登録しました。しかし、私はaddNewIncomingCallメソッドを呼び出した後に何も起こりません。私は何が欠けているの任意のアイデア?Android TelecomManagerのaddIncomingCallが何もしない

マニフェスト...

<service 
    android:name=".MyConnectionService" 
    android:label="example" 
      android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"> 
    <intent-filter> 
     <action android:name="android.telecom.ConnectionService"/> 
    </intent-filter> 
</service> 

活動...私は少なくともonCreateIncomingConnection

@RequiresApi(api = Build.VERSION_CODES.M) 
public class MyConnectionService extends ConnectionService { 

private static String TAG = "MyConnectionService"; 


public MyConnectionService() { 
} 


@Override 
public Connection onCreateIncomingConnection(PhoneAccountHandle  connectionManagerPhoneAccount, ConnectionRequest request) { 
Log.i(TAG,"onCreateIncomingConnection"); 
return super.onCreateIncomingConnection(connectionManagerPhoneAccount, request); 
} 
} 
+0

私はそれを稼働させることもできました。しかし、電話がロックされているときに着信UIは、電話に応答するか拒否するためのアクションを含んでいません。理由は何か分かりますか? – rsiwady29

答えて

0

Iによって生成されたログに何かを見ることを望んでい

TelecomManager tm = (TelecomManager) getSystemService(Context.TELECOM_SERVICE); 
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { 

    PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(
      new ComponentName(this.getApplicationContext(), MyConnectionService.class), 
      "example"); 

    PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "example").setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER).build(); 
    tm.registerPhoneAccount(phoneAccount); 
    Bundle extras = new Bundle(); 
    Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, mNumber.getText().toString(), null); 
    extras.putParcelable(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS, uri); 
    extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandle); 
    tm.addNewIncomingCall(phoneAccountHandle, extras); 

} 

MyConnectionService MyConnectionServiceを単にMyServiceに改名 - 作業を開始しました。奇妙な!

関連する問題