Dual Sim Android

前端 未结 4 1876
春和景丽
春和景丽 2021-02-20 09:58

Is there a way that I can access the other sim in my android? I have an android Cherry Mobile Orbit which is a dual sim android phone. I want to develop an SMS application for m

4条回答
  •  温柔的废话
    2021-02-20 10:42

    Assuming that you are developing the app for your own phone, and you are willing to go through the trouble of finding out the IDs (sim_id) assigned to each of your SIM cards (probably via checking the phone's log outputs, searching for sim_id, which was what I did), you can use the following code to set the default SIM for SMS sending:

    int simId = ;
    Intent simIntent = new Intent("android.intent.action.SMS_DEFAULT_SIM");
    simIntent.putExtra("simid", simId);
    sendBroadcast(simIntent);
    

    Combined with some other UI prompt stuff (for actually 'picking' the preferred SIM), this should do the trick.

    I'm not at all sure if this approach would work for you (although the code seems quite 'standard'); I figured it out with trial and error on my Mlais MX28 (with a customized ROM). But it's still worth a shot, I suppose. :)

    UPDATE: Strangely, the solution stopped working unexpectedly after a few updates to the app I was working on. But I came across another way (which seems to be more promising). (I believe this can be extended for other SIM selection scenarios as well, as the settings cache contains entries with names gprs_connection_sim_setting, voice_call_sim_setting, video_call_sim_setting and the like.)

    ContentValues val = new ContentValues();
    val.put("value", "here goes the preferred SIM ID");
    getContentResolver().update(Uri.parse("content://settings/system"), val, "name='sms_sim_setting'", null);
    

    (Unfortunately, this requires the android.permission.WRITE_SETTINGS permission.)

提交回复
热议问题