2014-11-23 101 views
-1

我希望androidStartServiceOnBoot.class應該每次執行,但它只執行一次。AndroidStartServiceOnBoot.class在程序中只被調用一次..但我希望它每次調用

@Override public void onReceive(Context context,Intent intent){PowerManager pm =(PowerManager)context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,「Your TAG」); //獲取鎖 wl.acquire();正從烏爾PHP腳本或任何返回

  //You can do the processing here. 
     Bundle extras = intent.getExtras(); 
     StringBuilder msgStr = new StringBuilder(); 

     if(extras != null && extras.getBoolean(ONE_TIME, Boolean.FALSE)){ 
      //Make sure this intent has been sent by the one-time timer button. 
      msgStr.append("One time Timer : "); 
     } 
     Format formatter = new SimpleDateFormat("hh:mm:ss a"); 
     msgStr.append(formatter.format(new Date())); 
     Intent serviceIntent = new Intent(context, AndroidStartServiceOnBoot.class); 
     context.startService(serviceIntent); 
     Toast.makeText(context, msgStr + "test", Toast.LENGTH_LONG).show(); 
     //Release the lock 
     wl.release(); 
} 
+0

您嘗試解析的字符串不是有效的json。 – 2014-11-23 05:15:35

回答

0

響應... 被具有附裝作爲 1.echo「BR」一個
標籤----爲PHP 等....(刪除這對於PHP) 檢查你的響應返回從服務器..應該沒有
標記,同時返回來自服務器上的文件的響應

+0

我的PHP腳本..怎麼辦? <?php $ host =「127.0.0.1」; $ uname =「root」; $ pwd =「」; $ db =「mydata」; ($ host,$ uname,$ pwd)或死(「連接失敗」); \t mysql_select_db($ db,$ con)或die(「db selection failed」); \t \t $ mobile = $ _ REQUEST ['mno']; \t \t $ flag ['code'] = 0; \t $ result = mysql_query(「SELECT * FROM tracker where mobile like'$ mobile'」)或die(mysql_error()); \t如果(mysql_num_rows($結果)== 0){ \t \t 如果($ R =請求mysql_query( 「插入到跟蹤器的值( '$移動')」,$ CON)) \t { \t \t // $ flag [「code」] = 1; \t \t $ code = 1; \t \t \t } \t} \t回波json_encode($代碼); \t mysql_close($ con); ?> – 2014-11-23 08:15:29

相關問題