package com.extension.issinfo; import com.google.appinventor.components.annotations.DesignerComponent; import com.google.appinventor.components.annotations.SimpleObject; import com.google.appinventor.components.annotations.SimpleFunction; import com.google.appinventor.components.annotations.SimpleEvent; import com.google.appinventor.components.annotations.SimpleProperty; import com.google.appinventor.components.common.ComponentCategory; import com.google.appinventor.components.runtime.AndroidNonvisibleComponent; import com.google.appinventor.components.runtime.AndroidViewComponent; import com.google.appinventor.components.runtime.ComponentContainer; import com.google.appinventor.components.runtime.EventDispatcher; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import javax.net.ssl.HttpsURLConnection; @DesignerComponent(version = 1, description = "Created by Salman Developer", category = ComponentCategory.EXTENSION, nonVisible = true, iconName = "") @SimpleObject(external = true) public class IssInfo extends AndroidNonvisibleComponent { public IssInfo(ComponentContainer container) { super(container.$form()); } @SimpleFunction(description = "") public String GetIssJSON() { String url = "https://api.wheretheiss.at/v1/satellites/25544"; HttpsURLConnection con = null; try { URL u = new URL(url); con = (HttpsURLConnection) u.openConnection(); con.connect(); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); StringBuilder sb = new StringBuilder(); String line; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); return sb.toString(); } catch (MalformedURLException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } finally { if (con != null) { try { con.disconnect(); } catch (Exception ex) { ex.printStackTrace(); } } } return null; } }