Android app - getting webpage content error -


currently code getting contents of html code (note starts @ line 45):

public string refresh() {     try {         string link = "http://amethystmc.com/staff/android/serverstatus_essential.php?auth=android420";          url url = new url(link);         urlconnection c = url.openconnection();         inputstream r = c.getinputstream();         bufferedreader reader = new bufferedreader(new inputstreamreader(r));          stringbuilder sb = new stringbuilder();         string line = null;          // read server response         while ((line = reader.readline()) != null) {             sb.append(line);             break;         }         return sb.tostring();     } catch (exception ex) {         string stacktrace = "";          (stacktraceelement string : ex.getstacktrace()) {             stacktrace += string + "\n";         }         log.e("internet died", stacktrace);         return new string("exception: " + stacktrace);     } } 

this error that's being thrown in console:

06-13 17:45:51.980  19907-19907/? e/internet died. android.os.strictmode$androidblockguardpolicy.onnetwork(strictmode.java:1166) java.net.inetaddress.lookuphostbyname(inetaddress.java:385) java.net.inetaddress.getallbynameimpl(inetaddress.java:236) java.net.inetaddress.getallbyname(inetaddress.java:214) com.android.okhttp.internal.dns$1.getallbyname(dns.java:28) com.android.okhttp.internal.http.routeselector.resetnextinetsocketaddress(routeselector.java:216) com.android.okhttp.internal.http.routeselector.next(routeselector.java:122) com.android.okhttp.internal.http.httpengine.connect(httpengine.java:292) com.android.okhttp.internal.http.httpengine.sendsocketrequest(httpengine.java:255) com.android.okhttp.internal.http.httpengine.sendrequest(httpengine.java:206) com.android.okhttp.internal.http.httpurlconnectionimpl.execute(httpurlconnectionimpl.java:345) com.android.okhttp.internal.http.httpurlconnectionimpl.getresponse(httpurlconnectionimpl.java:296) com.android.okhttp.internal.http.httpurlconnectionimpl.getinputstream(httpurlconnectionimpl.java:179) me.lukewizzy.servers.mainactivity.refresh(mainactivity.java:51) me.lukewizzy.servers.mainactivity.oncreate(mainactivity.java:25) android.app.activity.performcreate(activity.java:5458) android.app.instrumentation.callactivityoncreate(instrumentation.java:1093) android.app.activitythread.performlaunchactivity(activitythread.java:2376) android.app.activitythread.handlelaunchactivity(activitythread.java:2470) android.app.activitythread.access$900(activitythread.java:174) android.app.activitythread$h.handlemessage(activitythread.java:1307) android.os.handler.dispatchmessage(handler.java:102) android.os.looper.loop(looper.java:146) android.app.activitythread.main(activitythread.java:5593) java.lang.reflect.method.invokenative(native method) java.lang.reflect.method.invoke(method.java:515) com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1283) com.android.internal.os.zygoteinit.main(zygoteinit.java:1099) dalvik.system.nativestart.main(native method) 

this contents of manifest:

<uses-sdk     android:minsdkversion="8"     android:targetsdkversion="17"/> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" />  <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" >  <activity     android:name="me.lukewizzy.servers.mainactivity"     android:label="@string/app_name">      <intent-filter>         <action android:name="android.intent.action.main" />         <category android:name="android.intent.category.launcher" />     </intent-filter>  </activity> </application> 

after doing research i'm pretty sure i've given right permissions i've no idea i'm going wrong. i'd grateful can help.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -