android - Encapsulating SMS sending and receiving in a class -


i want create class take phone number, send sms number , wait answer specific number. planned this:

public class smartsocket extends broadcastreceiver {      private string mphonenum;     private smartsocketmessagelistener mlistener;      public smartsocket(string phonenum, smartsocketmessagelistener l) {         mphonenum = phonenum;         mlistener = l;     }      void requeststatus() {         smsmanager smsman = smsmanager.getdefault();         smsman.sendtextmessage(mphonenum, null, "status", null, null);     }      public void onreceive(context context, intent intent) {         //.... process received intent, extract phone number          if (phonenumfrom == mphonenum) {             //... we've got answer, process             mlistener.statusmessagereceived(messagetext);         }     }  } 

but not possible because android needs empty constructor class , creates new instance every time message received. there way around or pattern achieve need? want avoid application level variables might solve problem.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -