我正在尝试通过php脚本将我的android应用程序与mysql数据库连接。我已经尝试了一切,没有什么进展顺利。那么请你告诉我为什么我会收到这个错误,我该如何修复它。我只想在屏幕上显示查询,所以我可以确定我已连接并继续编码。
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class MainActivity extends AppCompatActivity {
String category;
String JSON_String;
String json_string;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new BackgroundTask().execute();
}
class BackgroundTask extends AsyncTask<Void, Void, String>
{
String json_url;
@Override
protected void onPreExecute() {
json_url="http://10.0.2.3/webappdb/get_all_rows.php";//Script
//super.onPreExecute();
}
@Override
protected String doInBackground(Void... params) {
try {
URL url = new URL(json_url);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
InputStream inputStream = httpURLConnection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder stringBuilder = new StringBuilder();
while ((JSON_String = bufferedReader.readLine())!=null){
stringBuilder.append(JSON_String + "\n");
}
bufferedReader.close();
inputStream.close();
httpURLConnection.disconnect();
return stringBuilder.toString().trim();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(String result) {
TextView textView = (TextView) findViewById(R.id.textview);
textView.setText(result);
json_string=result;
}
}
}
错误列表
04-01 07:40:12.580 26083-26083/? D/dalvikvm: Late-enabling CheckJNI
04-01 07:40:12.600 26083-26089/? E/jdwp: Failed sending reply to debugger: Broken pipe
04-01 07:40:12.600 26083-26089/? D/dalvikvm: Debugger has detached; object registry had 1 entries
04-01 07:40:12.692 26083-26083/? W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
04-01 07:40:12.692 26083-26083/? I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
04-01 07:40:12.692 26083-26083/? W/dalvikvm: VFY: unable to resolve interface method 15039: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
04-01 07:40:12.692 26083-26083/? D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-01 07:40:12.692 26083-26083/? I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
04-01 07:40:12.692 26083-26083/? W/dalvikvm: VFY: unable to resolve interface method 15043: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
04-01 07:40:12.692 26083-26083/? D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-01 07:40:12.748 26083-26083/? I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
04-01 07:40:12.748 26083-26083/? W/dalvikvm: VFY: unable to resolve virtual method 396: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
04-01 07:40:12.748 26083-26083/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-01 07:40:12.748 26083-26083/? I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
04-01 07:40:12.748 26083-26083/? W/dalvikvm: VFY: unable to resolve virtual method 418: Landroid/content/res/TypedArray;.getType (I)I
04-01 07:40:12.748 26083-26083/? D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-01 07:40:12.828 26083-26087/? D/dalvikvm: GC_CONCURRENT freed 180K, 15% free 2674K/3132K, paused 26ms+1ms, total 29ms
04-01 07:40:12.996 26083-26083/? D/libEGL: loaded /system/lib/egl/libEGL_genymotion.so
04-01 07:40:13.008 26083-26083/? D/libEGL: loaded /system/lib/egl/libGLESv1_CM_genymotion.so
04-01 07:40:13.008 26083-26083/? D/libEGL: loaded /system/lib/egl/libGLESv2_genymotion.so
04-01 07:40:13.076 26083-26083/? W/EGL_genymotion: eglSurfaceAttrib not implemented
04-01 07:40:13.084 26083-26083/? E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache
04-01 07:40:13.100 26083-26083/? E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints()