use
Value(con.getInputStream().toString);
use
Value(con.getInputStream().toString);
Sorry, that was wrong.try this :
String inputLine;
String output = "";
while ((inputLine = in.readLine()) != null) {
output = output + inputLine;
}
Value( output );
but where is inputstream
i think it should rd.readLine
But i don't know much more i am trying this first time
The input stream is the
Which is rd with your code.
So You can change it the code to
String inputLine;
In
String output = "";
while ((inputLine = rd.readLine()) != null) {
output = output + inputLine;
}
Value( output );
yeah, thanks
now i have 5 errors
can i pm you my code??
Yes you can
sent
Be aware that on Android 2.3 and higher you will likely get a NetworkOnMainThreadException due to the fact that you're trying to do an HTTP request on the main thread. Typically you need to launch the HTTP request on a separate thread using something like AsynchUtil. See the Web component as an example.
Hi @ewpatton sir I again tried to do as you said but my app is crashing after exporting.
public void Get(final String website) {
AsynchUtil.runAsynchronously(new Runnable() {
@Override
public void run() {
try {
URL url = new URL(website);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
BufferedReader bufferedReader = null;
if (httpURLConnection.getResponseCode() == 200) {
bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream()));
} else {
bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getErrorStream()));
}
StringBuilder stringBuilder = new StringBuilder();
String str;
while ((str = bufferedReader.readLine()) != null) stringBuilder.append(str);
bufferedReader.close();
final String data = stringBuilder.toString();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Getdata(data);
}
});
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
Does it crash when app open or when you call the block?
It is crashing when I put that block. (After button clicking)
Please try this if you want a simple get request. This works fine.
Also, see logs what is the error occurred. Use log reader extension, it helped me also (ask sunny)
Still same happening
That shouldn't happen.
Can you post the logs here?
Something is wrong in my side. Same extension was compiled by @Kumaraswamy and it worked but when I compiled it crashed again. I will reinstall sources.