I'm trying to learn client-server-communication with Android and php with this tutorial:
So I was successful to make the App (exactly the one in the tutorial) and the php-script works, too (I have tested it with the chrome-extention "Advanced Rest Client").
But when I'm running the app and clicking on the button to send the data, the text in the TextView (I setted it to "hello world" to test it) dissappears and nothing else happens. The TextView stays clear.
In the manifest-file I included the
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
before the application-tag.
What can I do now?
So I putted out the exeptions and got:
10-02 11:56:41.816 13275-13275/? V/Helloagain﹕ android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1133)
at java.net.InetAddress.lookupHostByName(InetAddress.java:410)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:241)
at java.net.InetAddress.getAllByName(InetAddress.java:219)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
at .MainActivity.GetText(MainActivity.java:99)
at .onClick(MainActivity.java:54)
at android.view.View.performClick(View.java:4421)
at android.view.View$PerformClick.run(View.java:17904)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)
10-02 11:56:41.826 13275-13275/? V/Helloagain﹕ java.lang.NullPointerException
at .MainActivity.GetText(MainActivity.java:134)
at .MainActivity$1.onClick(MainActivity.java:54)
at android.view.View.performClick(View.java:4421)
at android.view.View$PerformClick.run(View.java:17904)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5214)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
at dalvik.system.NativeStart.main(Native Method)