私は Android の初心者で、php ページを接続するアプリを開発しています。ただし、コードをデバッグすると、Source not found
Last time it given it for DefaulRequestDirector.class
;が表示されます。しかし、それはまたそれを与えましたAbstracthttpclient.class
。json
とapache
パッケージをインポートしました。
私はそれSource not found
をHttpResponse httpResponse = httpClient.execute(httpPost);
行で見ます。
if(method == "POST")
{
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost); // Source not found
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
LogCat:
05-15 16:15:46.133: W/dalvikvm(25727): threadid=1: thread exiting with uncaught exception (group=0x415262a0)
05-15 16:15:46.138: E/AndroidRuntime(25727): FATAL EXCEPTION: main
05-15 16:15:46.138: E/AndroidRuntime(25727): android.os.NetworkOnMainThreadException
05-15 16:15:46.138: E/AndroidRuntime(25727): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
05-15 16:15:46.138: E/AndroidRuntime(25727): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
05-15 16:15:46.138: E/AndroidRuntime(25727): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
05-15 16:15:46.138: E/AndroidRuntime(25727): at java.net.InetAddress.getAllByName(InetAddress.java:214)
05-15 16:15:46.138: E/AndroidRuntime(25727): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
05-15 16:15:46.138: E/AndroidRuntime(25727): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
05-15 16:15:46.138: E/AndroidRuntime(25727): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
05-15 16:15:46.138: E/AndroidRuntime(25727): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
05-15 16:15:46.138: E/AndroidRuntime(25727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
05-15 16:15:46.138: E/AndroidRuntime(25727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
05-15 16:15:46.138: E/AndroidRuntime(25727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-15 16:15:46.138: E/AndroidRuntime(25727): at com.example.yoritreader.JSONParser.makeHttpRequest(JSONParser.java:59)
05-15 16:15:46.138: E/AndroidRuntime(25727): at com.example.yoritreader.MainActivity$1.onPreviewFrame(MainActivity.java:246)
05-15 16:15:46.138: E/AndroidRuntime(25727): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:841)
05-15 16:15:46.138: E/AndroidRuntime(25727): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 16:15:46.138: E/AndroidRuntime(25727): at android.os.Looper.loop(Looper.java:137)
05-15 16:15:46.138: E/AndroidRuntime(25727): at android.app.ActivityThread.main(ActivityThread.java:4921)
05-15 16:15:46.138: E/AndroidRuntime(25727): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 16:15:46.138: E/AndroidRuntime(25727): at java.lang.reflect.Method.invoke(Method.java:511)
05-15 16:15:46.138: E/AndroidRuntime(25727): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
05-15 16:15:46.138: E/AndroidRuntime(25727): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
05-15 16:15:46.138: E/AndroidRuntime(25727): at dalvik.system.NativeStart.main(Native Method)
ご協力ありがとうございました!