I'm using reflection method for send messages from SIM card.
It working perfectly to send messages from default SIM by using "getDefault" method,
getContext().getClassLoader().loadClass("android.telephony.SmsManager").getMethod("getDefault", new Class[0]).invoke(null, new Object[0]);
But I want to send messages from selected SIM card (option given to select SIM card in my application).
I know, there is a method in SmsManager class to send message using SIM subscriptionID 'getSmsManagerForSubscriptionId(int subscriptionID)' added in API level 22 (lollipop).
It works perfectly using below code,
SmsManager.getSmsManagerForSubscriptionId(subscriptionID);
But I want to using by reflection method. So,when I'm using this method by reflection,
getContext().getClassLoader().loadClass("android.telephony.SmsManager").getMethod("getSmsManagerForSubscriptionId", Integer.class).invoke(null, subID);
It throws exception : 'java.lang.NoSuchMethodException: getSmsManagerForSubscriptionId [class java.lang.Integer]'
Can anyone tell me where I'm doing wrong?
Thanks.
Aucun commentaire:
Enregistrer un commentaire