Android Call Duration Periodic Reminder App

374 views Asked by At

I'm a newbie in Android Development. I am trying to develop an app that ends the active call on reaching particular call duration given by the user. I am using reflections to achieve this but, I'm stuck in. Can anybody help me continue?

My pgm goes like below:

if(intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(
                                    TelephonyManager.EXTRA_STATE_OFFHOOK)){

    //infinite loop until user duration exceeds
    while( <condtion I dont know>){
        if(userSeconds >= (System.currentTimeMillis() - start_time)){
            telephonyService.endCall();
        }       
    }


}
1

There are 1 answers

0
linvenuza On BEST ANSWER

finally found something which worked, really happy, now I'm sharing it... we can user java timers as well.. :)

 if(intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(
                                TelephonyManager.EXTRA_STATE_OFFHOOK)){


       //the handler runs once the user specified time period exceeds
       Handler handler=new Handler();handler.postDelayed(new Runnable() {
                @Override
           public void run() {
               // TODO Auto-generated method stub
               // write the code here that will be executed after desired milliseconds.     
               try {
                    telephonyService.endCall();
               } catch (RemoteException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
               }
           }

        }, userSeconds);
  }