下載開(kāi)發(fā)工具:https://developer.harmonyos.com
從鏈接
https://developer.harmonyos.com/cn/docs/documentation/doc-guides/document-outline-0000001064589184獲得開(kāi)發(fā)指南
遠(yuǎn)程模擬器
從集成開(kāi)發(fā)環(huán)境啟動(dòng)設(shè)備管理,使用遠(yuǎn)程仿真來(lái)模擬真機(jī),并在仿真器上運(yùn)行應(yīng)用。
從devEco入口
設(shè)定遠(yuǎn)程仿真器
在設(shè)備啟動(dòng)項(xiàng)目
一個(gè)Js項(xiàng)目
與寫(xiě)vue項(xiàng)目差異不大,只是工程上將js,css,h5分隔開(kāi)來(lái)。穩(wěn)定性還遠(yuǎn)遠(yuǎn)不夠。
例如:
hml
在頁(yè)面跳轉(zhuǎn)上出一些問(wèn)題,無(wú)法有效找到幫助。
錯(cuò)誤
關(guān)于手機(jī)傳感器的開(kāi)發(fā)、如位置的開(kāi)發(fā),js貌似無(wú)能為力。只能說(shuō)還是一個(gè)不太成熟的IDE,要想用得順暢,還是得靠JAVA。
一個(gè)native C++項(xiàng)目
extern "C"
JNIEXPORT jstring JNICALL
Java_com_example_myApplication_slice_MainAbilitySlice_stringFromJNI(JNIEnv* env, jobject obj) {
std::string hello = "Hello from JNI C++ codes";
int len = hello.size();
jchar res[len];
for (int i = 0; i < len; i++) {
res[i] = (jchar)hello[i];
}
return env->NewString(res, len);
}
在java中如此加載
public class MainAbilitySlice extends AbilitySlice {
// Load the 'native-lib' library on application startup.
static {
System.loadLibrary("hello");
}
private PositionLayout myLayout = new PositionLayout(this);
@Override
public void onStart(Intent intent) {
super.onStart(intent);
LayoutConfig config = new LayoutConfig(LayoutConfig.MATCH_PARENT, LayoutConfig.MATCH_PARENT);
myLayout.setLayoutConfig(config);
ShapeElement element = new ShapeElement();
element.setShape(ShapeElement.RECTANGLE);
element.setRgbColor(new RgbColor(255, 255, 255));
myLayout.setBackground(element);
Text text = new Text(this);
text.setText(stringFromJNI());
text.setTextColor(Color.BLACK);
myLayout.addComponent(text);
super.setUIContent(myLayout);
}
@Override
public void onActive() {
super.onActive();
}
@Override
public void onForeground(Intent intent) {
super.onForeground(intent);
}
/**
* A native method that is implemented by the 'native-lib' native library,
* which is packaged with this application.
*/
public native String stringFromJNI();
}
主服務(wù)框架中引用slice
public class MainAbility extends Ability {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setMainRoute(MainAbilitySlice.class.getName());
}
}
總之新品還是有很多亟待改善的地方