Access Api In Extension

i want to access an api in my extension
means like web component
i want to add one function = get
and other event got
so i search on internet but confused
can anyone give a simple source
i even seen ai source code of web component but still cant find solution

You can create a Web component inside of your extension. This also applies to other App Inventor components.

com.google.appinventor.components.runtime

This library includes all components from App Inventor. As you can see from here:

2 Likes

I really dont know how to do it​:sweat_smile:

I have already checked it
But thanks

http://3nportal.com/AIBridge/API/com/google/appinventor/components/runtime/Web.html

You just need to create a new variable with Web component type.

Web w = new Web(container);

Replace container with your ComponentContainer.

ComponentContainer
Components that can contain other components need to implement this interface.

1 Like

Thanks thats helpful to everyone :grin::kissing_heart:

  @SimpleFunction(description="t")
   public void GetOnlineRes(){
    
     Web w = new Web(GetOnlineRes);
     urlString = "apiergrgerger.xyz";
     public void Get() 
     }   

is it ok:sweat_smile:

can i get an simple example:cold_face:

Yes why not.
Following example shows how to get response content from Google’s website.

    public static String Web() throws IOException {
    StringBuilder result = new StringBuilder();
    URL u = new URL("https://www.google.com");
    HttpURLConnection web = (HttpURLConnection) u.openConnection();
    BufferedReader rd = new BufferedReader(new InputStreamReader(web.getInputStream()));
    String line;
    while ((line = rd.readLine()) != null) {
        result.append(line);
    }
    rd.close();
    return String.valueOf(result);
}
2 Likes

Thanks :grin:
But the thing i wanted is Available Now!:blush:

1 Like

Thank you so much

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