Can you help me in building an extension?

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.
image

(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. :sweat:
Can anybody help me to create this extension.

Error

error: ')' expected
[javac] }
[javac] ^
[javac] 1 error
[javac] 4 warnings

Please see this-

I read all the post replies in the post but not found any clue.
I wanted to get content directly into string. Without Got text, so that looping is done.

Can you please help me @Alpha2020?

In this-

You can see that You should do network operations on another thread. Meaning you should not return any information from network instead use a void to put the request and event block to capture the information otherwise a NetworkOnMainThread will be raised.

Okay, it means i am not allowed to do in same thread. If i do that then exception is thrown..??

Now, the problem is how can i perform loop in web component :sweat:

Oh, its easy to do. please wait.....

Try this-


This is for the same URL

1 Like

Thankyou....

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.