Quick App Generation for Test by Quick App IDE - Huawei Developers

Mre information like this, you can visit HUAWEI Developer Forum​
Do you want to test a web page whether is functional or not before providing solutions to CPs you can use Quick App IDE for testing just in a few steps:
1) Create a new project by using File > New Project > New QuickApp Project... direction. Enter App Name, Package Name and select "Hello World" template.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2) Open "hello.ux" file folder and paste following script. You only need to change loadUrl adress that you want to test e.g. https://developer.huawei.com/consumer/en/doc/
Code:
template>
<div class="doc-page">
<!-- Replace the link to the HTML5 app -->
<web class="web-page" src="{{loadUrl}}" trustedurl="{{list}}" onpagestart="onPageStart" onpagefinish="onPageFinish"
onmessage="onMessage" ontitlereceive="onTitleReceive"
onerror="onError" id="web"
supportzoom="{{supportZoom}}"
wideviewport="{{wideViewport}}}"
overviewmodeinload="{{overViewModeLoad}}"
useragent="{{ua}}"
allowthirdpartycookies="{{allowThirdPartyCookies}}">
</web>
</div>
</template>
<style>
.doc-page {
flex-direction: column;
flex-direction: column;
justify-content: center;
align-content: center;
align-items: center;
width: 100%;
height: 100%;
position: fixed;
}
.web-page {
width: 100%;
height: 100%;
}
</style>
<script>
import router from "@system.router";
export default {
props: ['websrc'],
data: {
title: "",
// TODO Replace the link to the H5 app
loadUrl: "https://developer.huawei.com/consumer/en/doc/",
// Attribute allowthirdpartycookies, indicates whether cookies can be delivered in cross-domain mode.
// If you need login Google Account or Other Account, Please set TRUE.
allowThirdPartyCookies: true,
//Attribute supportzoom, indicates whether the H5 page can be zoomed with gestures.
supportZoom:true,
wideViewport:true,
overViewModeLoad:true,
ua:"default",
// Here the whitelist settings, when the loading page has multiple addresses, such as the successful loading of the login address and the inconsistent entry address, it needs to set the whitelist to do so.
list: ["new RegExp('https?.*')"]
},
onInit() {
console.info('onInit: ');
},
onPageStart(e) {
console.info('pagestart: ' + e.url)
},
// Each page switch triggers
onPageFinish(e) {
console.info('pagefinish: ' + e.url, e.canBack, e.canForward);
},
onTitleReceive(e) {
this.title = e.title;
},
onError(e) {
console.info('pageError : ' + e.errorMsg)
},
onMessage(e) {
console.info('onmessage e = ' + e.message + ", url = " + e.url);
},
onShow: function () {
console.info(" onshow");
},
onHide: function () {
console.info(" onHide");
},
onBackPress() {
console.log('onBackPress')
this.$element('web').canBack({
callback: function (e) {
if (e) {
console.log('web back')
this.$element('web').back()
} else {
console.log('router back')
router.back()
}
}.bind(this)
})
return true
},
}
</script>
3) Put your app icon under Common folder. E.g. developer.png
4) Open manifest.json file and paste follwing script and change icon name with the file that you uploaded under Common folder.
Code:
{
"package": "com.testapp.huwei",
"name": "TestApp",
"versionName": "1.0.0",
"versionCode": 1,
"icon": "/Common/developer.png",
"minPlatformVersion": 1060,
"features": [
{
"name": "system.configuration"
},
{
"name": "system.calendar"
},
{
"name": "system.prompt"
},
{
"name": "system.router"
}
],
"permissions": [
{
"origin": "*"
}
],
"config": {},
"router": {
"entry": "Hello",
"pages": {
"Hello": {
"component": "hello"
}
}
},
"display": {
"titleBar":false
}
}
4) Create .rpk package by using Build > Run Release direction.
5) Accept IDE to create a signature file for your app.
6) com.testapp.huawei_release_1.0.0.rpk package has been generated and ready for test.
For more details...
Links
How can we convert an H5 app into a Quick App with Online Conversion:
https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201240455899740095&fid=0101188387844930001

Related

Integrate Ads kit in Flutter Application

More articles like this, you can visit HUAWEI Developer Forum
In this article we will be working on HMS Ads kit and integrate into a flutter application.
In first part we will work on the setup part and in second part we will work on implementing the ads in application.
Step 1: Create a project in AGC console
Step 2: You have to install flutter and dart plugin to android studio. Go to File -> Settings -> Plugins
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Once both are installed it will show you an option to create a new project in flutter.
To confirm run the below command in terminal “flutter doctor”
If you are still facing any issue in setup please comment below and I will make sure to resolve them.
Step 3: Download the folder and add in in your workspace where your flutter project resides.
https://developer.huawei.com/consumer/en/doc/HMS-Plugin-Library-V1/flutter-sdk-download-0000001050196675-V1
Step 4: Open pubspec.yaml file and add the below code.
Code:
huawei_ads:
path: ../huawei_ads/
..means to go 2 step backwards in folder and Huawei_ads is the folder name which you downloaded in previous step.
Once you change the pubspec.yaml file it will ask you to get the dependencies.
Click on pub get button highlighted above and you can get the latest dependencies.
Below message should be shown if the step goes successful.
To confirm the above step is successful you can also open external libraries and check flutter plugin added to it.
Step 5: Open the android project level gradle file and add below code.
Code:
dependencies {
classpath 'com.huawei.agconnect:agcp:1.2.1.301'
}
add below code in buildscript and allprojects section of gradle file
Code:
maven { url 'https://developer.huawei.com/repo/' }
Step 6: Go to app level gradle file and add below dependencies and agc services
Code:
implementation 'com.huawei.hms:ads-lite:13.4.30.301'
implementation 'com.huawei.hms:ads-consent:3.4.28.305'
implementation 'com.huawei.hms:ads-identifier:3.4.28.313'
implementation 'com.huawei.hms:ads-installreferrer:3.4.28.313'
Code:
apply plugin: 'com.huawei.agconnect'
Step 7: Add the agconnect-services.json into android -> app folder
Till here your initial setup is completed.
Now you have to create a UI where you can showcase your ads.
I am using a RaisedButton in order to call the logic of ads creation. You can use your own triggering mechanism in order to show the ads.
Banner Ads:
Code:
import 'package:flutter/material.dart';
import 'package:huawei_ads/hms_ads_lib.dart';
class BannerAds extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Align(
alignment: Alignment.topCenter,
child: RaisedButton(
child: Text(
'Load Banner Ads',
),
onPressed: () {
BannerAd _bannerAd = createBannerAd();
_bannerAd
..loadAd()
..show();
},
),
);
}
}
BannerAd createBannerAd() {
return BannerAd(
adUnitId: "testw6vs28auh3",
size: BannerAdSize(width: 360, height: 57),
adParam: AdParam.build(),
);
}
Make sure you use the proper imports
Create a method which returns BannerAd
I am using test add id but you can use your own add id.
I am showcasing with 2 banner size but you can modify them according to your need.
Call the load add and show add method to show the banner ad.
Below is the table from which you can choose ad size.
Below are the screenshot for Banner Ads
Splash Ads:
Code:
import 'package:flutter/material.dart';
import 'package:huawei_ads/hms_ads_lib.dart';
class SplashAds extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Align(
alignment: Alignment.topCenter,
child: RaisedButton(
child: Text(
'Load Splash Ads',
),
onPressed: () {
SplashAd splashAd = createSplash();
splashAd
..loadAd(
adUnitId: "testq6zq98hecj",
orientation: SplashAdOrientation.portrait,
adParam: AdParam.build(),
topMargin: 1);
},
),
);
}
}
SplashAd createSplash() => SplashAd(
adType: SplashAdType.above,
ownerText: 'Owner Text',
footerText: 'Footer Text',
loadListener: (SplashAdLoadEvent event, {int errorCode}) {
print("SplashAdLoadEvent : $event");
if (event == SplashAdLoadEvent.dismissed) {
//Handle Dismiss logic here
}
});
Create a method which returns SplashAd
I am using test add id but you can use your own add id.
topMargin can increase the margin space between splash and top border.
You can also define the orientation of add as well.
You can customize Owner text and Footer Text.
Below are the screenshot for Splash Ads
Interstitial Ads
Code:
import 'package:flutter/material.dart';
import 'package:huawei_ads/adslite/interstitial/interstitial_ad.dart';
class InterstitialAds extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Align(
alignment: Alignment.topCenter,
child: RaisedButton(
child: Text(
'Load Interstitial Ads',
),
onPressed: () {
InterstitialAd _interstitialAd = createInterstitialAd();
_interstitialAd
..loadAd()
..show();
},
),
);
}
}
InterstitialAd createInterstitialAd() {
return InterstitialAd(
adUnitId: "teste9ih9j0rc3",
);
}
Create a method which returns Interstitial Ad
I am using test add id but you can use your own add id.
Below are the screenshot for Interstitial Ad.
I hope you with the above snippets you can implement above three categories of ads.

Images Drawn by the canvas Component Cannot Be Displayed in the Album

Symptom
After an image drawn by the canvas component is saved to the album, the image cannot be displayed in the album. Only a black background image is displayed.
The image with green background in the following figure is drawn by the canvas component.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
After the image is saved to the album, the display result is as shown in the following figure.
Cause Analysis
Huawei Quick App Center creates a ctx object each time when it calls the getContext method, and therefore different ctx objects will be returned. Some of these ctx objects are empty. An empty ctx object may be obtained in a random selection. As a result, the image saved may have no content. The code is as follows:
Code for using canvas to draw an image:
HTML:
pic() {
var test = this.$element("canvas");
var ctx = test.getContext("2d");
var img = new Image();
img.src = "http://www.huawei.com/Assets/CBG/img/logo.png";
img.onload = function () {
console.log("Image loaded successfully");
ctx.drawImage(img, 10, 10, 300, 300, );
}
img.onerror = function () {
console.log("Failed to load the image");
}
},
Code for saving the image:
HTML:
save() {
var test = this.$element("canvas");
test.toTempFilePath({
fileType: "jpg",
quality: 1.0,
success: (data) => {
console.log(`Canvas toTempFilePath success ${data.uri}`)
console.log(`Canvas toTempFilePath success ${data.tempFilePath}`)
media.saveToPhotosAlbum({
uri: data.uri,
success: function (ret) {
console.log("save success: ");
},
fail: function (data, code) {
console.log("handling fail, code=" + code);
}
})
},
fail: (data) => {
console.log('Canvas toTempFilePath data =' + data);
},
complete: () => {
console.log('Canvas toTempFilePath complete.');
}
})
}
Solution
Define ctx as a global variable and check whether it is empty. Assign an initial value to an empty ctx.
Optimized code:
HTML:
var ctx; // Define a global variable.
pic() {
if (!ctx) {// Check whether a ctx object is empty. If it is empty, assign the 2d value to it.
var test = this.$element("canvas");
var tt = test.getContext("2d");
ctx = tt;
}
var img = new Image();
img.src = "http://www.huawei.com/Assets/CBG/img/logo.png";
img.onload = function () {
console.log("Image loaded successfully");
ctx.drawImage(img, 10, 10, 300, 300, );
}
img.onerror = function () {
console.log("Failed to load the image");
}
}

What Can I Do If an Image Drawn by the canvas Component Cannot Be Display

Symptom:
After an image drawn by the canvas component is saved to the album, the image cannot be displayed in the album. Only a black background image is displayed.
The image with the green background in the following figure is drawn by the canvas component.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
After the image is saved to the album, the display result is as shown in the following figure.
Analysis:
Huawei Quick App Loader creates a ctx object each time it calls the getContext method. Therefore, different ctx objects are returned, and some of these objects are empty. An empty ctx object may be obtained in a random selection. As a result, the saved image may have no content. The code where the exception occurs is as follows:
Code for using canvas to draw an image:
JavaScript:
pic() {
var test = this.$element("canvas");
var ctx = test.getContext("2d");
var img = new Image();
img.src = "http://www.huawei.com/Assets/CBG/img/logo.png";
img.onload = function () {
console.log("Image loaded successfully.");
ctx.drawImage(img, 10, 10, 300, 300, );
}
img.onerror = function () {
console.log("Failed to load the image.");
}
},
Code for saving the image:
JavaScript:
save() {
var test = this.$element("canvas");
test.toTempFilePath({
fileType: "jpg",
quality: 1.0,
success: (data) => {
console.log(`Canvas toTempFilePath success ${data.uri}`)
console.log(`Canvas toTempFilePath success ${data.tempFilePath}`)
media.saveToPhotosAlbum({
uri: data.uri,
success: function (ret) {
console.log("save success: ");
},
fail: function (data, code) {
console.log("handling fail, code=" + code);
}
})
},
fail: (data) => {
console.log('Canvas toTempFilePath data =' + data);
},
complete: () => {
console.log('Canvas toTempFilePath complete.');
}
})
}
Solution:
Define ctx as a global variable and check whether it is empty. Set an initial value for an empty ctx.
The optimized code is as follows:
JavaScript:
var ctx; // Define a global variable.
pic() {
if (!ctx) { // Check whether a ctx object is empty. If it is empty, set its value to 2d.
var test = this.$element("canvas");
var tt = test.getContext("2d");
ctx = tt;
}
var img = new Image();
img.src = "http://www.huawei.com/Assets/CBG/img/logo.png";
img.onload = function () {
console.log("Image loaded successfully.");
ctx.drawImage(img, 10, 10, 300, 300, );
}
img.onerror = function () {
console.log("Failed to load the image.");
}
}
For more details, please check:
Quick app materials:
https://developer.huawei.com/consumer/en/doc/development/quickApp-Guides/quickapp-whitepaper
canvas component:
https://developer.huawei.com/consum...quickApp-References/quickapp-component-canvas
Intro to the canvas API:
https://developer.huawei.com/consumer/en/doc/development/quickApp-References/quickapp-api-canvas

HTML5 Quick App Website Internationalization

Background
I needed to develop a function for dynamically loading HTML5 websites that matched the system language. The website internationalization in my project was implemented by dynamically loading URLs. For example, if the system language of a mobile phone is Japanese, the URLs of web pages in Japanese are loaded. For simplified Chinese, those in simplified Chinese are loaded, and for English, those in English are loaded, and so on. Here, I have listed the steps for your reference.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Solution
Step 1: Bind a variable.
Bind a variable to the src attribute of the web component, to ensure that the attribute will not have a fixed value. In the following code, loadUrl in {{}} is a bound variable. It is defined under script in the UX file. You can skip this step if your project was created using the HTML5 template in Huawei Quick App IDE, downloaded from https://developer.huawei.com/consumer/en/doc/development/quickApp-Guides/quickapp-installtool, because the variable will be bound by the template code.
JavaScript:
<!-- template -->
<web src="{{loadUrl}}"
</web>
<!-- script -->
export default {
data: {
loadUrl: "https://transit.navitime.com/en",
},
Step 2: Initialize the variable.
Use the onInit() method in the quick app’s lifecycle to call the device API to obtain the system language and load the HTML5 page in the obtained language.
JavaScript:
onInit: function () {
const device = require("@system.device")
const res = device.getInfoSync();
let local = res.language; //system language
let region = res.region; //system region
console.info('onInit :localole= ' + local + ", region=" + region);
if (local === 'zh') {
if (region === "CN") {
this.loadUrl = "https://transit.navitime.com/zh-cn/";
} else if (region === "TW") {
this.loadUrl = "https://transit.navitime.com/zh-tw/";
}
} else if (local === 'ja') {
this.loadUrl = "https://transit.navitime.com/ja/?from=huawei.quickapp";
} else {
// For other languages, the HTML5 page in the default language is used.
this.loadUrl = "https://transit.navitime.com/en";
}
},
Step 3: Add a listener for system language switch.
Perform this step if you want the language on the HTML5 page to change accordingly, as the user changes the system language when the HTML5 quick app is running. You can skip this step if you don’t need to implement this function. The user can simply exit the app and re-enter it.
The code for adding a listener to listen to the system language switch is as follows:
JavaScript:
onConfigurationChanged(object) {
console.log("onConfigurationChanged object=" + JSON.stringify(object));
if (object.type === "locale") {
const configuration=require("@system.configuration")
var localeObject = configuration.getLocale();
let local= localeObject.language;
let region= localeObject.countryOrRegion;
console.info(onConfigurationChanged(object :localole= ' + local + ", region=" + region);
if (local === 'zh') {
if (region === "CN") {
this.loadUrl = "https://transit.navitime.com/zh-cn/";
} else if (region === "TW") {
this.loadUrl = "https://transit.navitime.com/zh-tw/";
}
} else if (local === 'ja') {
this.loadUrl = "https://transit.navitime.com/ja/?from=huawei.quickapp";
} else {
// For other languages, the HTML5 page in the default language is used.
this.loadUrl = "https://transit.navitime.com/en";
}
}
},
Summary
I hope you’ll find this post helpful, when planning the global release of your HTML5 quick app. Feel free to leave a question or comment below, to share your own experiences.
It's an easy and useful code.
Rebis said:
It's an easy and useful code.
Click to expand...
Click to collapse
Thanks to your liking.

Tic Tac Toe Game using HTML5 Quick Game - Part 2

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Introduction
In my last article, we can learn the following:
What is Quick game?
Feature and advantage of Quick game.
Development procedure.
Installing development tools.
If you have not yet read my previous article read it here to understand more about quick game. Just to summarize in my previous article we have installed project and created the application in Quick app IDE.
In this article, we can learn the following:
Creating Quick Game.
Generating and configuring a certificate fingerprint.
Enabling Game service and Account kit.
Creating Quick Game
Step 1: Sign in to AppGallery Connect and click My apps.
Step 2: Click New App.
Step 3: Add all required information, then click OK.
Parameters information
Step 4: Navigate to project setting > General information add package details.
Step 5: Add Default data processing location.
Generating and configuring a certificate fingerprint.
Create certificate
Step 1: Open Quick App IDE and open an existing project or create new project.
Step 2: Choose Tools > Certificate
Step 3: If signature is not yet created, select Create else if already exist select Import.
Step 4: Add necessary information and click Create.
Step 5: Copy SHA-256 certificate fingerprint from output.
Configure the Certificate fingerprint in AppGallery
Step 1: Sign in to AppGallery and click My project
Step 2: Select the project which you want to configure the certificate fingerprint.
Step 3: Navigate to Project Settings > General information in the App information and enter the copied SHA-256 certificate.
Enable Game service.
Step 1: Sign in to AppGallery and click My project.
Step 2: Select the project which you want to enable Game service and account kit.
Step 3: Navigate to Project Settings > Manage API and enable account kit and Game service.
Build the HTML5 Quick Game
HTML:
<!-- HTML5 Quick Game Access Guidance -->
<!-- https://developer.huawei.com/consumer/en/doc/development/quickApp-Guides/quickgame-develop-h5-game-->
<template>
<div class="doc-page">
<!-- Replace the link to the HTML5 game -->
<web class="web-page" src="{{gameUrl}}" type="game" trustedurl="{{list}}" onpagestart="onPageStart"
fullscreendirection="{{fullscreenDirection}}" jumppolicy="{{linkJumpPolicy}}" multiwindow="{{openMultiwindow}}"
onpagefinish="onPageFinish" ontitlereceive="onTitleReceive" onerror="onError" id="web"
allowthirdpartycookies="{{allowThirdPartyCookies}}">
</web>
</div>
</template>
<style>
.doc-page {
flex-direction: column;
flex-direction: column;
justify-content: center;
align-content: center;
align-items: center;
}
.web-page {
width: 100%;
height: 100%;
}
</style>
<script>
import router from "@system.router"
import prompt from '@system.prompt'
export default {
props: ['websrc'],
data: {
title: "",
// TODO Replace the link to the H5 game
gameUrl: "https://codepen.io/timrijkse/full/XjLGKv/",
// Attribute allowthirdpartycookies, indicates whether cookies can be delivered in cross-domain mode.
// If you need login Google Account or Other Account, Please set TRUE.
allowThirdPartyCookies: true,
//Attribute fullscreendirection,controls the direction when the webpage requests full screen.
//If you want the full screen orientation to be vertical, please set it to portrait.
//The default value is landscape
fullscreenDirection: "landscape",
//If you want the ads in the game to be opened in the browser, please set the value of openMultiwindow
// to true and the value of linkJumpPolicy to browser
linkJumpPolicy: "default",
openMultiwindow: false,
// Here the trust list settings, when the loading page has multiple addresses, such as the successful loading of the login address and the inconsistent entry address, it needs to set the trust list to do so.
list: ["new RegExp('https?.*')"],
},
onPageStart(e) {
console.info('pagestart: ' + e.url)
},
// Each page switch triggers
onPageFinish(e) {
console.info('pagefinish: ' + e.url, e.canBack, e.canForward)
},
onTitleReceive(e) {
this.title = e.title;
},
onError(e) {
console.info('pageError : ' + e.errorMsg)
},
onMessage(e) {
console.info('onmessage e = ' + e.message + ", url = " + e.url);
prompt.showToast({
message: e.message + ': ' + e.url
})
},
isCanForward() {
this.$element('web').canForward({
callback: function (e) {
if (e) {
this.$element('web').forward();
}
}.bind(this)
})
},
isCanBack() {
this.$element('web').canBack({
callback: function (e) {
if (e) {
this.$element('web').back();
} else {
router.back();
}
}.bind(this)
})
},
onShow: function () {
console.info(" onshow");
},
onHide: function () {
console.info(" onHide");
},
onBackPress() {
const prompt = require('@system.prompt')
prompt.showDialog({
message: 'Whether to quit the html5 game?',
buttons: [
{
text: 'Cancel'
},
{
text: 'Exit'
}
],
success: (data) => {
console.log('handling callback', data.index)
if (data.index === 1) {
this.$app.exit()
}
},
cancel: function () {
console.log('handling cancel')
},
fail: function (data, code) {
console.log(`handling fail, code = ${code}`)
}
})
return true
},
}
</script>
Result
Tips and Tricks
Understand About Quick Game.
Explore some Quick Game from phone.
Install all the required tools.
Make sure you have configured the adb in the desktop or laptop.
Command to install Quick App loader APK is adb install quickapploader.apk
Enable Game service and account kit.
Conclusion
In this article, we have learnt about creating Quick Game, generating and configuring the SHA-256 fingerprint certificate, Enabling game service and account kit and building HTML5 Quick Game application.
Reference
Quick Game official document
Download tools from here
Beginner: Find the Explanation of Quick Game Part 1
thanks for sharing

Categories

Resources