I have tried with code mentioned on this link How to send a SMS using SMSmanager in Dual SIM mobile? I used name for simID is "isms_msim".
try {
if (simID == 0) {
name = "isms";
} else if (simID == 1) {
name = "isms_msim";
} else {
throw new Exception("can not get service which for sim '" + simID + "', only 0,1 accepted as values");
}
Method method = Class.forName("android.os.ServiceManager").getDeclaredMethod("getService", String.class);
method.setAccessible(true);
Object param = method.invoke(null, name);
method = Class.forName("com.android.internal.telephony.ISms$Stub").getDeclaredMethod("asInterface", IBinder.class);
method.setAccessible(true);
Object stubObj = method.invoke(null, param);
if (Build.VERSION.SDK_INT < 18) {
method = stubObj.getClass().getMethod("sendMultipartText", String.class, String.class, List.class, List.class, List.class);
method.invoke(stubObj, toNum, centerNum, smsTextlist, sentIntentList, deliveryIntentList);
} else {
method = stubObj.getClass().getMethod("sendMultipartText", String.class, String.class, String.class, List.class, List.class, List.class);
===> method.invoke(stubObj, ctx.getPackageName(), toNum, centerNum, smsTextlist, sentIntentList, deliveryIntentList);
}
return true;
} catch (ClassNotFoundException e) {
Logger.Log(TAG, Logger.LogLevel.ERROR, "Error while sending multiple sms, stack trace: " + e.getStackTrace());
} catch (NoSuchMethodException e) {
Logger.Log(TAG, Logger.LogLevel.ERROR, "Error while sending multiple sms, stack trace: " + e.getStackTrace());
} catch (InvocationTargetException e) {
Logger.Log(TAG, Logger.LogLevel.ERROR, "Error while sending multiple sms, stack trace: " + e.getStackTrace());
} catch (IllegalAccessException e) {
Logger.Log(TAG, Logger.LogLevel.ERROR, "Error while sending multiple sms, stack trace: " + e.getStackTrace());
} catch (Exception e) {
Logger.Log(TAG, Logger.LogLevel.ERROR, "Error while sending multiple sms, stack trace: " + e.getStackTrace());
}
but this code is giving following Exception on line starts with ===> in else block: SecurityException: Binder invocation to an incorrect interface
Any Idea about it ?
I got the solution by myself after spending some time. call the API from https://github.com/gp-b2g/frameworks_base/blob/master/telephony/java/android/telephony/MSimSmsManager.java and https://github.com/gp-b2g/frameworks_base/blob/master/telephony/java/android/telephony/MSimTelephonyManager.java file by java reflection to get subscription info and to send SMS.