コード例 #1
0
 private void doReportFinish() {
   if (DEBUG) Log.d(TAG, "doReportFinish");
   try {
     JSONObject jdata = new JSONObject();
     jdata
         .put("action", "report finish")
         .put("priority", 10)
         .put("report_counts", mReportCounts)
         .put("reporter", Utility.getMyToken(this))
         .put("delay_while_idle", false);
     JSONObject root = new JSONObject();
     root.put("to", mReturnAddress);
     root.put("data", jdata);
     Utility.sendMessageAsync(
         this,
         root.toString(),
         new Utility.AsyncTaskCallback() {
           @Override
           void onPostExecute() {
             stopSelf();
           }
         });
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
コード例 #2
0
 private void doReportStart() {
   if (DEBUG) Log.d(TAG, "doReportStart");
   try {
     JSONObject jdata = new JSONObject();
     jdata
         .put("action", "report starting")
         .put("priority", 10)
         .put("reporter", Utility.getMyToken(this))
         .put("delay_while_idle", false);
     JSONObject root = new JSONObject();
     root.put("to", mReturnAddress);
     root.put("data", jdata);
     Utility.sendMessageAsync(this, root.toString());
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
コード例 #3
0
 private void doReportLocation(Location l) {
   if (DEBUG) Log.d(TAG, "doReportLocation");
   try {
     JSONObject jdata = new JSONObject();
     jdata
         .put("action", "report location")
         .put("latitude", l.getLatitude())
         .put("longitude", l.getLongitude())
         .put("provider", l.getProvider())
         .put("time", l.getTime())
         .put("reporter", Utility.getMyToken(this))
         .put("priority", 10)
         .put("delay_while_idle", false);
     JSONObject root = new JSONObject();
     root.put("to", mReturnAddress);
     root.put("data", jdata);
     Utility.sendMessageAsync(this, root.toString());
     mReportCounts++;
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }