Android has an IccCard interface. It is in the com.android.internal.telephony package. This package is not included in the Android SDK , and, accordingly, is not available for free access. I am interested in his method - getIccLockEnabled() , which will return me a value of type boolean . In this excellent answer, I learned a lot, but still it’s impossible to realize my plans. As I understand it, you first need to use the getInstance() and getUiccCard() methods of the com.android.internal.telephony.uicc.UiccController class. Since the getInstance() method is static, I need to pass simple null to invoke . But for some reason, Exception crashes (line 5)

 java.lang.reflect.InvocationTargetException 

Here is my code:

 Class uiccController = Class.forName("com.android.internal.telephony.uicc.UiccController"); log("Класс найден"); Method getInstance = uiccController.getMethod("getInstance"); log("Метод найден"); Object instance = getInstance.invoke(null); log("instance взят"); Method getCard = instance.getClass().getMethod("getUiccCard"); log("Метод найден"); Object card = getCard.invoke(instance); log("принято"); Method getLockEnabled = card.getClass().getMethod("getIccLockEnabled"); log("выполняем метод"); boolean result = (Boolean) getLockEnabled.invoke(card); log("принят отаювет!"); log(result?"true":"false"); 

UPD

Fantasy!!! I found this question on enSO !!! The code has the first line, but I don’t understand what phoneUtil

  • And what does he write in the error message? There should be a message and a reason (caused by) - Andrew Bystrov
  • You see, the fact of the matter is that this is all) I myself am in shock - Flippy
  • put try ... catch, and make printStackTrace () errors - Vladyslav Matviienko
  • he and so in try / catch - Flippy
  • updated the question, look at the code in question on enSO - Flippy

0