当前位置:网站首页>Appinventor development
Appinventor development
2022-04-22 22:43:00 【Taoist incense】
Why develop and expand ?
Want to use appinventor There are only two ways beyond the functions supported by the standard .
1. Directly modifying appinventor Source code , Add new features , Then use this private customized server .
2. Write and expand , Can be added to anything that works appinventor Service .
The advantage of the second is obvious , The expansion form of official support , It eliminates the need for users to build appinventor Service effort .
Expand the development environment
If you have built a standard appinventor service , You can directly use this environment for development .
But if you haven't built it yet appinventor service , Because the overall service construction process is slow after all , And contains redundant service parts (2G many ), So we can use it to do extension Development environment of :
Basic development steps
First download the library :
git clone --recurse-submodules https://github.com/mit-cml/extension-template.git my-extension
And then in src New in folder MyExtension.java project :
package cn.temp;
import com.google.appinventor.components.annotations.*;// annotation
import com.google.appinventor.components.common.ComponentCategory; // Component category
import com.google.appinventor.components.runtime.*;
ava Utility class library for java.util package . In this bag ,Java Some practical methods and data structures are provided . for example ,Java Provide date (Data) class 、 The calendar (Calendar) Class to generate and get the date and time , Provide random numbers (Random) Class generates various types of random numbers , A stack is also provided (Stack)、 vector (Vector) 、 Bit set (Bitset) And hash table (Hashtable) And other classes to represent the corresponding data structure .
import com.google.appinventor.components.runtime.util.*;
import com.google.appinventor.components.runtime.errors.YailRuntimeError;
@DesignerComponent(version = MyExtension.VERSION, // Designer component
description = "by Aheadtechs.", // remarks , describe
category = ComponentCategory.EXTENSION, // Category : On display in appinventor Which module of
nonVisible = true, // invisible
iconName = "images/extension.png") // Component icon
@SimpleObject(external = true) // External plug-ins
public class MyExtension extends AndroidNonvisibleComponent {
public static final int VERSION = 1; // If a data is both static again final, Then it will have an unchangeable storage space
private static final String LOG_TAG = "MyExtension";
public MyExtension(ComponentContainer container) { // Memory skills :contain contain , accommodate + er Watch things → Containers
// You can call the properties or methods of the parent class through super keyword . adopt super To get the private properties of the parent class
super(container.$form());
}
// Calculation a+b The sum of is then converted into a string
@SimpleFunction(description = "add up a and b")
public String addab(int a,int b) {
return ""+(a+b);
}
}
Then it can be called :
ant extensions
After the compilation is successful, a... Will be generated in the root directory of the project out Folder , Among them is what we need .aix Postfix file .
Note that the form of expansion is .aix Postfix file .
Advanced development
Although it can meet our basic needs , But the real development process needs more than a simple example of this , We may need to add third-party libraries !
For example, a special communication protocol :opcua And so on. .
The specific steps are as follows :
1. Download the corresponding library jar file , And copy to lib/deps Folder :

And then in Myextension.java Add... To the file :
@SimpleObject(external = true) // External plug-ins
// You can't put it in this position ! Must be in SimpleObject below
@UsesLibraries(libraries = "opc-ua-stack-1.4.1-224.jar,slf4j-api-1.7.0.jar")
Recompile , You can put the jar Add the content of to the generated .aix In file , You can easily see from the size of the file .
The call is the same as a normal call :
import org.opcfoundation.ua.application.Client;
...
Reference documents :
版权声明
本文为[Taoist incense]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222204196474.html
边栏推荐
猜你喜欢

深开鸿新闻直播间首次开播 共同见证时代成长全历程

Overview of working principle and main characteristics of ATOS proportional valve

强化学习(实践):REINFORCE,AC
![[summary of scattered knowledge points 5]](/img/a6/6700f00b01bc59fc0366d64071ac41.png)
[summary of scattered knowledge points 5]

小赛毛游C记——初识C语言(3)

CAS统一身份认证(三):外部独立配置

51 MCU proteus simulation key control nixie tube digital display

Reinforcement learning (practice): dqn, double dqn, dueling dqn

MySql--- 数据类型

【洛谷】P1162 填涂颜色(bfs)
随机推荐
3.20-4.20 近期项目经验总结
CAS统一身份认证(二):Overlay配置管理
【MMUB】基于Hidden Markov model的手机用户行为建模——Hidden Markov model
No more simple intention lock
MySql内置函数
LLVM 学习(三) -样例学习
[wechat applet development (cloud wallpaper applet tutorial)]
外部中断---------stm32f407zet6
GBase 8s V8.8 SQL 指南:教程-6.2.1(3)
意大利阿托斯电磁阀的工作性质是什么?
2.58-编写程序is-little-endian,当在小端法机器上编译和运行时返回1,在大端法机器上编译和运行时则返回0。这个程序应该可以运行在任何机器上,无论机器的字长是多少。
[Luogu] p1162 filling color (BFS)
Implementation of multi-layer perceptron from scratch (extracting function from D2L package)
Reinforcement learning (practice): feedback, AC
Hydraulic shock analysis of haWe haWe hydraulic pump station
GBase 8s V8. 8 SQL Guide: Tutorial - 6.2.2 (1)
用forEach和ES6实现tab切换
未来可期,PlatoFarm的生态通证登录Bitmart等全球四大平台
51 MCU proteus simulation key control nixie tube digital display
A journey to C by Xiao Sai Mao -- first understanding of C language (3)
https://github.com/mit-cml/extension-template