0
我正在Intentservice的onHandleIntent()方法內部運行一個簡單的fql查詢。不知道問題是什麼,查詢部分沒有被執行。這裏是我的onHandleIntent()方法Android IntentService問題
protected void onHandleIntent(Intent intent)
{
System.out.println("inside service method now");
String fqlQuery = "SELECT uid, username, online_presence, status FROM user WHERE uid = 100001024732884";
Bundle params = new Bundle();
params.putString("q", fqlQuery);
Session session = Session.getActiveSession();
Request request = new Request(session,
"/fql",
params,
HttpMethod.GET,
new Request.Callback(){
public void onCompleted(Response response) {
System.out.println("inside the service now 4444");
Log.i(TAG, "Result: " + response.toString());
}
});
Request.executeBatchAsync(request);
}
只打印第一條語句。
當我把我的MainActivity相同的代碼它工作正常,但在IntentService它停止工作。我正在按鈕上啓動服務。
您必須嘗試先發現錯誤。這個方法必須拋出一些錯誤。使用try catch方法並捕獲錯誤。那麼你可能可以解決這個問題。 –
你的意思是隻有'現在服務4444'內部打印? – gunar
不,只有第一個打印語句正在執行。 – user1872750