Overview

Quick apps are a new form of installation-free apps developed based on industry standards formulated by Quick App Alliance, which consists of mainstream mobile phone manufacturers in China. A quick app can be distributed to all mobile phones that support industry standards without adaptation.
Benefits for you:

What You Will Create

In this codelab, you will create a simplified browser using Huawei Quick App IDE, which supports the following functions:

  1. A search box: Users can enter the search content in the box and search for documents published on HUAWEI Developers.
  2. QR code scanning: Users can scan a QR code to directly open a web page.
  3. Browse history saving: When a user exits the browser, the currently opened address will be saved. When the user opens the browser again, the last opened page will be displayed.

What You Will Learn

Hardware Requirements

Software Requirements

Required Knowledge

Android app development basics

Before developing a quick app, you must complete the following preparations:

For details, please refer to Preparations for Quick Start.
  1. Open Huawei Quick App IDE. Go to New Project > Quick App, select Phone/Tablet, and then click Next.
  2. Click the Common tab, select Hello World, and click Next.
  3. Configure project information and click Ok.

Now, you have successfully created a quick app project.

  1. Use a USB cable to connect the test device to a computer where Huawei Quick App IDE is installed. Enabling the Developer Options on a Huawei Phone
  2. If the connection is successful, select the file to be compiled and debugged, and click Run.
  3. Select the device on the Selecting Running Device page and click Confirm.
  4. If your test device has not installed Huawei Quick App Loader, click Install in the dialog box displayed in the lower right corner. Otherwise, skip this step.
  5. View the compilation effect on the simulator.

Editing the Template

The browser web page is vertically arranged, with the search area and display area.

Editing the Style

Replace the information in the style element of the hello.ux file to implement the CSS style of the search and display areas.

<style> .container { flex-direction: column; justify-content: center; align-items: center; padding: 15px; } .content { width: 100%; height: 100%; margin-top: 50px; } .header div { border: 1px solid #afafff; padding: 20px; } .header .scan, .header .search { width: 20%; } .header .scan text, .header .search text { margin: 0 auto; } .header input { width: 60%; } </style>

Editing the Script

Define all required service logic in the script element, to implement functions such as scanning an object, recording inputs, searches, and obtaining and saving the current URL.

<script> import barcode from '@system.barcode'; import storage from '@system.storage'; module.exports = { data: { componentData: {}, // Default web page. url: 'https://developer.huawei.com/consumer/en/quickApp', searchWord: '', }, // Scanning function. scanCode() { let that = this; barcode.scan({ success: function (data) { console.log('handling success: ' + data.result); that.url = data.result; }, fail: function (data, code) { console.log('handling fail, code = ' + code); } }) }, // Input recording. changeWord(e) { this.searchWord = e.value; }, //search search() { this.$element('selectionInput').focus({ focus: false }) this.url = "https://developer.huawei.com/consumer/en/doc/search?val=" + this.searchWord; }, // Obtaining and saving the current URL. onPageFinish(e) { console.log('pagefinish: ' + e.url); storage.set({ key: 'webUrl', value: e.url, success: function (data) { console.log("handling success"); }, fail: function (data, code) { console.log("handling fail, code = " + code); } }) }, // Implement the onBackPress callback when a user exits a web page. onBackPress() { this.$element('web').canBack({ callback: function (e) { if (e) { this.$element('web').back(); } else { let router = require('@system.router'); router.back() } }.bind(this) }) return true; }, // Obtain the saved URL when the user re-opens the web page. onInit() { let that = this; storage.get({ key: 'webUrl', success: function (data) { console.log("handling success:", data); that.url = data; }, fail: function (data, code) { console.log("handling fail, code = " + code); } }) this.$page.setTitleBar({ text: 'BrowserDemo', textColor: '#ffffff', backgroundColor: '#007DFF', backgroundOpacity: 0.5, menu: true }); } } </script>

Editing the Manifest

Open the manifest.json file and declare the usage performance.

"features": [ {"name": "system.barcode"}, {"name": "system.storage"}],
  1. After your test device is connected to the PC, click Run.
  2. The default web page is displayed when a user opens the browser, which is the official website of Quick App in this demo.
  3. Enter the keyword quickapp, and click search. Then the search result is displayed.
    Click ×. Then click Run in IDE to relaunch the app. The last page accessed is displayed.

  4. Click scan to activate the mobile phone camera.

  5. Scan the following QR code. The web page is displayed successfully.

  1. Select the file to be debugged. Click Debug to start debugging.
  2. Check output logs.

  3. After the debugging process is started, the system opens the debugging window.

  4. Click Debug again to stop the debugging process. Log information records Debug service has been closed.

  1. Go to Build > Run Release from the main menu to package the release version RPK.
  2. If there is no signature file, in the dialog box that is displayed in the lower right corner, click Create to create a signature file.
  3. On the Create Signature page for confirming the creation of a signature file, click Create.
  4. If a signature file is available, click Run Release. The Packaging Formal Versions page is displayed. You can edit the version name and version code. After the packaging is complete, the dist directory of the project automatically opens. The RPK package generated in this directory can be submitted to AppGallery Connect for review. Once the package is approved, the app will be available on AppGallery.

Well done. You have successfully completed this codelab and learned how to:

For more information, please refer to the following documents:

Quick App Guides

Quick App References

Code copied