Today i was facing a problem while using the web component in a loop. I have created something like below where i have to call web in the loop.
First time in the loopmweb1.get is occured but without going to web1.got text , it will again go to second loop .
Thats why i am unable to get text from web five times.
(My english is not good but i hope you are understanding)
So i thought of creating an extension that will directly return string without gottext block. I searched community and found the way i can get the response content so i wrote for it something like that,
@SimpleFunction(description="Get content directly")
public String GetContent(final String url){
AsynchUtil.runAsynchronously(new Runnable(){
@Override
public void run(){
BufferedReader readStream = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
String readLine;
StringBuilder data = new StringBuilder();
while ((readLine = readStream.readLine()) != null) data.append(readLine);
readStream.close();
final String finalData = data.toString();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
return finalData;
}
}
}
});
}
But its not working and error is coming.
Can anybody help me to create this extension.
Error
error: ')' expected
[javac] }
[javac] ^
[javac] 1 error
[javac] 4 warnings