Tuesday, July 22, 2014

Requesting location by SMS

Struggling with the location request through SMS for a long long time. It seems to be simple and straight forward, but, in fact, it is not as easy as I thought. There is only one chance (SMS) to return the most accurate location to the sender.

What I have changed to the app is

  1. Tried to save some precious battery for not connecting the network if the GPS is turned on, but seems did not work out.

    The appropriate way is first check the status of GPS (on/off) and check if GPS signal is available. Will apply that in later stage.

    Currently, connect to the network regardless the GPS is on or not. The GPS is turned on, but the GPS signal could be unavailable. The location acquired, therefore, is out-dated.



  • private void connectNetworkBySMS()

    1.     {    
    2.    
    3.     if(appSettings.getBoolean(AppSettings.Key_SMS_MobileData, false))
    4.     {
    5.     enableMobileData();
    6.     }
    7.    
    8.     if(appSettings.getBoolean(AppSettings.Key_SMS_Wifi, false))
    9.     {
    10.     enableWifi();
    11.     }
    12.    
    13.     isWaitingForResponse = true;
    14.    
    15.     }
    2. Validate contact for code #10 or #STATUS only, proceed other information without validation
      1. if((code.indexOf("#10")!=-1||code.indexOf("#STATUS")!=-1)
      2.      &&
      3.       appSettings.getBoolean(AppSettings.Key_SMS_AllowSMSRequest, false)
      4.        &&contactsManager.IsTrusted(userId))
      5.       {
      6.      connectNetworkBySMS(); 
      7.      queuelRequest(userId);   
      8.       }
      9.       if(code.indexOf("#BEGIN")!=-1 && code.indexOf("#END")!=-1)
      10.       {     
      11.      Position p = updatePositionDB(senderNum, code);
      12.       }
      Okay, that's all for today, good night!

      No comments:

      Post a Comment

      Applying SMA10/20, SMA20/50 as trading signals

      This is the comparison for results before and after applying SMA10/20 and SMA20/50 in the stock trader. Background Trading 3 stock ma...