I'm working on an android application in order to calling some phone numbers, sequentially. For example, there are 3 editText that each of them contains a specific phone number and after calling the first number, a delay will occur before calling the second number, and so on.
But when I start calling, I see (isn't app responding) message and there is no log in (logcat). What is the solution? The codes are as follows:
  private void onClickCall() {
        check = true;
        sumSms = 0;
          delayCall = Integer.parseInt(editTextDelayCall.getText().toString());
        repeatCall = Integer.parseInt(editTextRepeatCall.getText().toString());
        for (int j=0;j<phoneNumberList.size();j++)
        for (int i = 0; i <repeatCall; i++) {
            Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumberList.get(i).getPhoneNumber()));
            startActivity(intent);
            try {
                Thread.sleep(delayCall);
                endCall(context);
            } catch (InterruptedException ie) {
                Thread.currentThread().interrupt();
                Log.e("0", ie + "");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
And end call method :
 private void endCall(Context context) throws Exception {
        String serviceManagerName = "android.os.ServiceManager";
        String serviceManagerNativeName = "android.os.ServiceManagerNative";
        String telephonyName = "com.android.internal.telephony.ITelephony";
        Class<?> telephonyClass;
        Class<?> telephonyStubClass;
        Class<?> serviceManagerClass;
        Class<?> serviceManagerNativeClass;
        Method telephonyEndCall;
        Object telephonyObject;
        Object serviceManagerObject;
        telephonyClass = Class.forName(telephonyName);
        telephonyStubClass = telephonyClass.getClasses()[0];
        serviceManagerClass = Class.forName(serviceManagerName);
        serviceManagerNativeClass = Class.forName(serviceManagerNativeName);
        Method getService = serviceManagerClass.getMethod("getService", String.class);
        Method tempInterfaceMethod = serviceManagerNativeClass.getMethod("asInterface", IBinder.class);
        Binder tmpBinder = new Binder();
        tmpBinder.attachInterface(null, "fake");
        serviceManagerObject = tempInterfaceMethod.invoke(null, tmpBinder);
        IBinder retbinder = (IBinder) getService.invoke(serviceManagerObject, "phone");
        Method serviceMethod = telephonyStubClass.getMethod("asInterface", IBinder.class);
        telephonyObject = serviceMethod.invoke(null, retbinder);
        telephonyEndCall = telephonyClass.getMethod("endCall");
        telephonyEndCall.invoke(telephonyObject);
    }
 
     
     
    