2016-09-02 10 views
1

私のデバイスの2番目のSIMカードから電話をかける方法はありますか?私はこのように見つけました。2つのSIMカードを使ってアンドロイドでインテントを呼び出す

Intent callIntent = new Intent(Intent.ACTION_CALL); 
    callIntent.putExtra("simSlot", selectedSlot); 
    callIntent.setData(Uri.parse("tel:" + tel)); 
    startActivity(callIntent); 

ここで、selectedSlotは0または1(1番目または2番目のsim)です。しかし、それは仕事をする。私は

callIntent.putExtra("com.android.phone.extra.slot", selectedSlot); 

行目に行

callIntent.putExtra("simSlot", selectedSlot); 

を交換しますが、それはあまりにも仕事をdoesnt。では、どうすれば2番目のSIMカードから電話をかけることができますか?このコードで

答えて

0

チェック:

final Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumberOrUssd)); 
    final int simSlotIndex = 1; //Second sim slot 

    try { 
     final Method getSubIdMethod = SubscriptionManager.class.getDeclaredMethod("getSubId", int.class); 
     getSubIdMethod.setAccessible(true); 
     final long subIdForSlot = ((long[]) getSubIdMethod.invoke(SubscriptionManager.class, simSlotIndex))[0]; 

     final ComponentName componentName = new ComponentName("com.android.phone", "com.android.services.telephony.TelephonyConnectionService"); 
     final PhoneAccountHandle phoneAccountHandle = new PhoneAccountHandle(componentName, String.valueOf(subIdForSlot)); 
     intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", phoneAccountHandle); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    context.startActivity(intent); 

それはときAPI> 23残念ながら、それだけで動作します。このlink

+0

からです。どのように私はosのバージョン4.1または4.3でこれを行うことができますか? –

関連する問題