2017-01-09 1 views
1

내 앱에 문제가 있습니다. 내 앱에 자동 시작 기능이 있으며 항상 'BOOT_COMPLETED'라는 브로드 캐스트를 수신합니다. 내 맞춤 서비스에서 루프 요청을 수행하고 싶습니다. (startService)를 5 초마다 실행합니다. 앱을 실행하면 모든 것이 잘 보이는 것 같습니다. 내 휴대 전화를 재부팅하면 문제가 발생합니다. 앱이 자동 시작될 수 있기 때문에 아무 것도하지 않고 로그 만 볼 것입니다. this the fail log pic전화를 재부팅하고 연결을 거부했습니다. (

만 첫 번째 요청은 다른 모든 실패, 성공 것이다 (org.apache.http.conn.HttpHostConnectException가 : http://10.0.27.46:8090에 연결이 거부) .B 응용 프로그램 아이콘을 클릭하여 실행하면 모든 요청이 성공적으로 처리됩니다. 나는이 문제를 해결 캔트

, pls는 저를 도와 :)

public void onReceive(Context context, Intent intent) { 
    if (intent.getAction().equals(BOOT_ACTION) || intent.getAction().equals(QUICKBOOT_ACTION) || intent.getAction().equals(REBOOT_ACTION)) { 
     Intent mainActivityIntent = new Intent(); 
     mainActivityIntent.setAction("GrayService"); 
     mainActivityIntent.setPackage("com.wyk.accessibilityservicewx"); 
     context.startService(mainActivityIntent); 
    } 
} 


try { 
    String uriAPI = "http://10.0.27.46:8090/crm/insert_customer_resource.json"; 
    HttpPost httpRequest = new HttpPost(uriAPI); 
    List <NameValuePair> params = new ArrayList <NameValuePair>(); 
    params.add(new BasicNameValuePair("str", "I am Post String")); 
    httpRequest.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); 
    HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest); 
    if (httpResponse.getStatusLine().getStatusCode() == 200) { 
     String strResult = EntityUtils.toString(httpResponse.getEntity()); 
     LogUtil.log("====success:" + strResult); 
    } else { 
     LogUtil.log("====fail code:" + httpResponse.getStatusLine().getStatusCode()); 
    } 
} catch (Exception e) { 
    e.printStackTrace(); 
    LogUtil.log("====fail code:" + e.toString()); 
} 
+0

각 요청 후에 연결이 닫히지 않으시겠습니까? –

답변

0

나는 좋았지 문제가 .I 내 응용 프로그램은 설정에서 자동으로 시작 할 수 있도록해야 내 전화 시스템 (샤오 미)에 의해 casued 고정.

관련 문제