如何使用UserMetric发布消息到Welcome Screen
来源:互联网 发布:java基础教程视频 编辑:程序博客网 时间:2024/06/15 15:45
我们可以通过UserMetric的API发布消息到我们手机的欢迎页面(手机的锁屏界面)。在锁屏界面中,我们可以双击中间的圆圈,来循环播放我们手机发布的消息。如下图所示,
我们发布了“Useermetric messages received: 4”个消息。
我们需要使用的模块是:
import UserMetrics 0.1
我们可以使用如下的方法得到它所有的API:
liuxg@liuxg:~$ qmlplugindump import UserMetrics 0.1QQmlComponent: Component is not readyliuxg@liuxg:~$ qmlplugindump UserMetrics 0.1import QtQuick.tooling 1.1// This file describes the plugin-supplied types contained in the library.// It is used for QML tooling purposes only.//// This file was auto-generated by:// 'qmlplugindump UserMetrics 0.1'Module { Component { name: "Metric" prototype: "QObject" exports: ["Metric 0.1"] exportMetaObjectRevisions: [0] Property { name: "name"; type: "string" } Property { name: "format"; type: "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: "increment" } Method { name: "update" Parameter { name: "value"; type: "double" } } }}
我们的应用非常简单:
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" /* This property 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(60) height: units.gu(85) 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("Decrease") onClicked: { console.log("Going to increase the metric bye 2!"); incomingMessagesMetric.increment(-2) } } Button { text: i18n.tr("Decrease") onClicked: { console.log("Going to update to 3 to the metric!"); incomingMessagesMetric.update(3) } } } }}
为了使用UserMetric,我们必须在我们的应用中使用usermetrics security policy:
usermetrics.apparmor
{ "policy_groups": [ "networking", "webview", "usermetrics" ], "policy_version": 1.3}
每当我们点击increase按钮后,我们的欢迎界面数据将增加一个:
整个应用的源码在:https://github.com/liu-xiao-guo/usermetrics
0 0
- 如何使用UserMetric发布消息到Welcome Screen
- 如何使用screen
- windows 7 welcome screen twicks
- [XD] Welcome screen欢迎界面
- 如何使用office2010发布blog到csdn
- Android welcome screen when cold boot
- 如何使用VS发布ASP.NET应用到Windows Azure
- 如何使用AndroidStudio将开源项目library发布到jcenter
- 准确使用welcome
- 使用screen
- screen 使用
- screen 使用
- screen使用
- screen使用
- screen 使用
- The welcome screen disappears after lock the computer.
- print 'welcome to masm!' in the center of the screen.
- Dynamics CRM2013 禁止欢迎界面(Disable the Welcome Screen)
- Android系统自带样式(android:theme)(转)
- linux内核链表使用
- 使用了Autolayout的UITableViewCell动态布局和高度动态改变自适应
- muduo网络库源码学习————Timestamp.cc
- oracle 日期格式
- 如何使用UserMetric发布消息到Welcome Screen
- zzuli OJ 1063: 最大公约与最小公倍
- Java反射机制深入详解
- 图解测试之稳定性-了解稳定性测试
- 《IOS_C语言--进制,C数据类型、常量、变量、运算符、表达式、格式化输入输出》
- Android-插入/查询联系人/短信收到提醒(内容观察者)
- Hadoop学习笔记
- java给图片添加水印文字
- ofbiz 相关