broadcastreceiver - How can I check whether response is came within one minute after sending SMS in android? -


i creating application in sending sms automatically on button click.when sms sent response server in form of sms.i read message , perform task on it. problem when receive sms want consider messages received within 1 minute after button click. do.?

public class incomingsms extends broadcastreceiver {   @override public void onreceive(context context, intent intent) {        global mapplication = ((global)context.getapplicationcontext());     string getppn=mapplication.getppn();     string getstatus=mapplication.getvstatus();     string clientid=mapplication.getvclientid();     string mobileno=mapplication.getvstrmobile();     string locationid=mapplication.getvstrlocation();     string imei=mapplication.getvstrimei();      final bundle bundle = intent.getextras();     try {         if (bundle != null)         {             final object[] pdusobj = (object[]) bundle.get("pdus");             (int = 0; < pdusobj .length; i++)             {                 smsmessage currentmessage = smsmessage.createfrompdu((byte[]) pdusobj[i]);                 string phonenumber = currentmessage.getdisplayoriginatingaddress();                 string sendernum = phonenumber ;                    string message = currentmessage .getdisplaymessagebody();                  mapplication.setvsendernumber(sendernum);                 mapplication.setvmessagebody(message);                 string isbroadcast=mapplication.getvauthenticateduser();                  try                 {                     if(isbroadcast=="1")                     {                         context.sendbroadcast(new intent("message_recived"));                     }                     }                 catch(exception e){}              }         }      } catch (exception e)     {      } } 

}

this class called when sms received , take me arming activity's on receive method. need that..broadcast receiver receive message within 1 minute after sendinf sms

armingactivity:

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_arming);     registerreceiver(broadcastreceiver, new intentfilter("message_recived"));}   broadcastreceiver broadcastreceiver = new broadcastreceiver() {     @override     public void onreceive(context context, intent intent) {         // internet lost alert dialog method call here...      //   if(strppn.equals())         global globalvariable = (global) getapplicationcontext();         string vvsendernumber=globalvariable.getvsendernumber();         string vvmessagebody=globalvariable.getvmessagebody();         string vvppn=strppn;             };   public void sendsms(string ppn, string smsbody) {      try {          smsmanager smsmanager = smsmanager.getdefault();         smsmanager.sendtextmessage(ppn, null, smsbody, null, null);       } catch (exception e) {         e.printstacktrace();     }    }     if (stractiontext.equals("1"))  {    sendsms(strppn, msgbody); } 

here when send sms start broadcast receiver start receiving sms 1 minute. do?

you can handler

for start/register receiver , start handler 1 minute

//start broadcast here. new handler().postdelayed(new runnable() {          @override         public void run() {             // write code stop/unregister receiver.          }     }, 60*1000); 

for further display time can use countdowntimer class.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -