【发布时间】:2017-06-18 23:43:27
【问题描述】:
以下是logcat中的错误结果:
这是我的代码:
【问题讨论】:
-
欢迎来到 Stack Overflow! Please don't post your code as an image.
-
还有一个重要的阅读:stackoverflow.com/help/mcve 为了得到好的答案,你应该问一个具体的问题而不是转储错误日志。
以下是logcat中的错误结果:
这是我的代码:
【问题讨论】:
你加了吗
<uses-permission android:name="android.permission.INTERNET" />
进入 AndroidManifest.xml ? 您可以尝试使用 post 方法将代码发送到服务器。
@Override
protected Void doInBackground(Void... params) {
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost("https://192.168.2.95/LAfinal/api/login_student.php");
// ADD YOUR DATA
List<NameValuePair> nameValuePairs = new ArrayList<>();
nameValuePairs.add(new BasicNameValuePair("id", _activity.LOGINED_USER_ID));
Log.v("HTTP", "Response__activity.LOGINED_USER_ID: " + String.valueOf(_activity.LOGINED_USER_ID));
nameValuePairs.add(new BasicNameValuePair("token", _activity.fcmRegId));
Log.v("HTTP", "Response___activity.fcmRegId: " + _activity.fcmRegId);
nameValuePairs.add(new BasicNameValuePair("status", String.valueOf(_notificationStatus)));
Log.v("HTTP", "Response_notificationStatus: " + String.valueOf(_notificationStatus));
nameValuePairs.add(new BasicNameValuePair("type", "android"));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// EXECUTE HTTP POST REQUEST
HttpResponse response = httpClient.execute(httpPost);
HttpEntity resEntity = response.getEntity();
//resEntity.getContent().close();
int status = response.getStatusLine().getStatusCode();
if (status == 200) {
if (_notificationStatus == 1) {
WebViewActivity._needLogin = false;
} else {
WebViewActivity._needLogin = true;
}
}
if (resEntity != null) {
String responseStr = EntityUtils.toString(resEntity).trim();
Log.v("HTTP", "Response: " + responseStr);
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}`
【讨论】: