Androit Http Client GET işlemi
merhaba arkadaşlar uzak sunucuy get ile veri göndermek istiyorum fakat aşağıdaki kod android 2.3te sorunsuz çalışmasına rağamnen 4.2'de hata vermekte sebebi nedir acaba?
[code]
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.SUNUCUURL.com/server.php?deger1=deneme");
try {
httpclient.execute(httppost);
} catch (IOException e) {
}
[/code]
Aldığım Hata
[code]06-16 07:52:50.920: E/AndroidRuntime(2021): FATAL EXCEPTION: main
06-16 07:52:50.920: E/AndroidRuntime(2021): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.uzak/com.example.uzak.MainActivity}: android.os.NetworkOnMainThreadException
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.os.Handler.dispatchMessage(Handler.java:99)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.os.Looper.loop(Looper.java:137)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.app.ActivityThread.main(ActivityThread.java:5103)
06-16 07:52:50.920: E/AndroidRuntime(2021): at java.lang.reflect.Method.invokeNative(Native Method)
06-16 07:52:50.920: E/AndroidRuntime(2021): at java.lang.reflect.Method.invoke(Method.java:525)
06-16 07:52:50.920: E/AndroidRuntime(2021): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
06-16 07:52:50.920: E/AndroidRuntime(2021): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-16 07:52:50.920: E/AndroidRuntime(2021): at dalvik.system.NativeStart.main(Native Method)
06-16 07:52:50.920: E/AndroidRuntime(2021): Caused by: android.os.NetworkOnMainThreadException
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1133)
06-16 07:52:50.920: E/AndroidRuntime(2021): at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
06-16 07:52:50.920: E/AndroidRuntime(2021): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
06-16 07:52:50.920: E/AndroidRuntime(2021): at java.net.InetAddress.getAllByName(InetAddress.java:214)
06-16 07:52:50.920: E/AndroidRuntime(2021): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
06-16 07:52:50.920: E/AndroidRuntime(2021): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
06-16 07:52:50.920: E/AndroidRuntime(2021): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
06-16 07:52:50.920: E/AndroidRuntime(2021): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
06-16 07:52:50.920: E/AndroidRuntime(2021): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
06-16 07:52:50.920: E/AndroidRuntime(2021): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
06-16 07:52:50.920: E/AndroidRuntime(2021): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
06-16 07:52:50.920: E/AndroidRuntime(2021): at com.example.uzak.MainActivity.verigonder(MainActivity.java:50)
06-16 07:52:50.920: E/AndroidRuntime(2021): at com.example.uzak.MainActivity.onCreate(MainActivity.java:39)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.app.Activity.performCreate(Activity.java:5133)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-16 07:52:50.920: E/AndroidRuntime(2021): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
[/code]