How to use Usermetric to publish messages to welcome screen

Source: Internet
Author: User
Tags i18n

We can post messages via the Usermetric API to our phone's welcome page (the phone's lock screen). In the lock screen, we can double-hit the circle, to cycle through our mobile phone posted messages. As shown,

We have released a message "Useermetric messages Received:4".




The modules we need to use are:

Import Usermetrics 0.1

We can get all of its APIs using the following method:


[email protected]:~$ qmlplugindump Import usermetrics 0.1qqmlcomponent:component is not ready[email  protected]:~$ qmlplugindump usermetrics 0.1import qtquick.tooling 1.1//This file describes the Plugin-supplied types con tained in the library.//It's used for QML tooling purposes only.////This file was auto-generated by://' Qmlplugindump U        Sermetrics 0.1 ' Module {Component {name: ' Metric ' prototype: ' Qobject ' exports: ["Metric 0.1"] Exportmetaobjectrevisions: [0] Property {name: ' name '; Type: ' String '} property {name: ' Format '; typ        E: "String"} property {name: "Emptyformat"; Type: ' String '} property {name: "Domain"; Type: "String"}            Property {name: ' Minimum '; Type: ' Double '} property {name: ' Maximum '; Type: ' Double '} Method { Name: "Increment" Parameter {name: "Amount"; Type: "Double"}} Method {name: "Incremen T "} Method {NamE: "Update" Parameter {name: "value"; Type: "Double"}}} 


Our application is very simple:


Main.qml
Import QtQuick 2.0import ubuntu.components 1.1import usermetrics 0.1/*! \brief MainView with a Label and Button Elements.*/mainview {//ObjectName for functional testing purposes (autopilot- QT5) ObjectName: "MainView"//note!      ApplicationName needs to match the "name" field of the click Manifest ApplicationName: "Usermetrics.liu-xiao-guo"/* The enables the application to change orientation when the device is rotated.    The default is False.    *///automaticorientation:true//Removes the old toolbar and enables new features of the new header.        Usedeprecatedtoolbar:false width:units.gu (height:units.gu) page {title:i18n.tr ("Usermetrics")  Metric {id:incomingmessagesmetric name: "Usermetric" format:i18n.tr ("Usermetric            Messages received today:%1 ") emptyFormat:i18n.tr (" No usermetric messages received today. ") Domain:applicationname} ColuMN {anchors.centerIn:parent spacing:units.gu (2) Button {text:i18n.tr (                    "Increase") onclicked: {Console.log ("going to increase the metric!"); Incomingmessagesmetric.increment ()}} Button {text:i18n.tr ("Decr                    Ease ") onclicked: {Console.log (" going to increase the metric bye 2! "); Incomingmessagesmetric.increment ( -2)}} Button {text:i18n.tr ("D                    Ecrease ") onclicked: {Console.log (" going to update to 3 to the metric! "); Incomingmessagesmetric.update (3)}}}}


In order to use usermetric, we must use it in our applications. UsermetricsSecurity Policy:
Usermetrics.apparmor
{"    policy_groups": [        "Networking",        "WebView",        "Usermetrics"    ],    "policy_version": 1.3} 


To run our application:



Every time we click on the increase button, our welcome interface data will be added one:




The source code for the entire application is: Git clone https://gitcafe.com/ubuntu/usermetrics.git


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

How to use Usermetric to publish messages to welcome screen

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.