this can do the same thing too, so I think we don't need an extension for that @Meulencv
Still, it's okay for learning
But I ned to do this, to later do the extension more complex, for example a extension that gives the bitcoin price.
Hello,
I would be very grateful if you could fix my code, thank you very much
I have the demo extension code which works.
Demo code
File name: Request.java
package com.kumaraswamy.request;
import android.app.Activity;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.runtime.util.AsynchUtil;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
@DesignerComponent(version = 1,
category = ComponentCategory.EXTENSION,
description = "Made my YOU",
nonVisible = true,
iconName = "ICON LINK")
@SimpleObject(external = true)
public class Request extends AndroidNonvisibleComponent {
private Activity activity;
public Request(ComponentContainer container) {
super(container.$form());
activity = container.$context();
}
@SimpleFunction
public void DoRequest(final String website) {
AsynchUtil.runAsynchronously(new Runnable() {
@Override
public void run() {
BufferedReader in;
try {
in = new BufferedReader(
new InputStreamReader(
new URL(website).openStream()));
String inputLine;
final StringBuilder result = new StringBuilder();
while ((inputLine = in.readLine()) != null)
result.append(inputLine);
in.close();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
GotResult(result.toString());
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
@SimpleEvent
public void GotResult(String result) {
EventDispatcher.dispatchEvent(this, "GotResult", result);
}
}
Thank you very much with all my heart @Kumaraswamy , I don't know how to thank you. IT WORKS!
used your code and got compile error in kodular
Kodular is unable to compile this project.
The compiler error output was
________Preparing application icon
________Creating animation xml
________Creating fragment xml
________Creating listview xml in res/layout/..
________Creating listview xml in res/layout-v21/..
________Creating xml in res/drawable/..
________Creating splash png in res/drawable/..
________Creating colors xml
________Creating styles xml
________Creating drawables xml v21
________Checking for firebase
________Creating provider_path xml
________Creating network_security_config xml
________Generating adaptive icon file
________Generating round adaptive icon file
________Generating adaptive icon background file
________Generating manifest file
________Attaching native libraries
________Attaching Android Archive (AAR) libraries
________Attaching component assets
________Invoking AAPT
AAPT time: 1.217 seconds
________Compiling source files
.
I'm solving the problem
I have solved the problem, thank you very much for the warning.
It's not the fault of the extension, I have compiled the code over two times...
Extensions. I added this extension to an empty project and it hasn't compiled anymore.
Hi, it compiles correctly for me and the app works on the mobile. Have you tried v2 of the extension?
It do like web scrapping,
When the extension get the source of the web page, it cut a part of the source to get the value like (btc price)
so i think it can be made without having to use extension?
Yes, but is more simple to use the extension
:cough:
yeah I think you are right, but it's also simple without having to use extensions.
And I've done it > Click this <
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.