怎麼在Ubuntu手機上傳送簡訊及撥打到電話,ubuntu傳送簡訊

來源:互聯網
上載者:User

怎麼在Ubuntu手機上傳送簡訊及撥打到電話,ubuntu傳送簡訊

由於一些平台安全性的原因,Ubuntu手機目前暫時沒有提供供第三方開發人員傳送簡訊及撥打到電話的介面,但是在實際的應用中,我們也許會需要用到傳送簡訊息或撥打到電話。這個時候我們怎麼辦呢?我們在前面的文章“使用URL dispatcher的範例”中已經介紹了如何使用url dispatcher來調用第三方應用的方法。這裡我們用該方法來展示如何在我們的應用中傳送簡訊息及撥打到電話。


首先,我們建立一個最簡單的“App with Simple UI”模版應用,並修改我們的“main.qml”檔案如下:


import QtQuick 2.0import Ubuntu.Components 1.1import Ubuntu.Components.ListItems 0.1 as ListItem/*!    \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: "com.ubuntu.developer.liu-xiao-guo.phone"    /*     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(50)    height: units.gu(75)    Page {        title: i18n.tr("Phone")        function call(phonenumber) {            Qt.openUrlExternally("tel:///" + encodeURIComponent(phonenumber))        }        function sendMessage(phonenumber, text) {            Qt.openUrlExternally("message:///" + encodeURIComponent(phonenumber))        }        Column {            spacing: units.gu(1)            anchors {                margins: units.gu(2)                fill: parent            }            Row {                anchors.horizontalCenter: parent.horizontalCenter                Label {                    anchors.verticalCenter: parent.verticalCenter                    text: i18n.tr("Number: ")                }                TextField {                    id: inputnumber                    placeholderText: "please type your phone number"                    text: "1111111111"                }            }            Button {                width: parent.width                text: i18n.tr("Call")                onClicked: {                    call(inputnumber.text)                }            }            ListItem.Divider {}            Row {                anchors.horizontalCenter: parent.horizontalCenter                Label {                    anchors.verticalCenter: parent.verticalCenter                    text: i18n.tr("Number: ")                }                TextField {                    id: inputnumber1                    placeholderText: "please type your phone number"                    text: "22222222222"                }            }            TextEdit {                id: messageText            }            Button {                width: parent.width                text: i18n.tr("Send Message")                onClicked: {                    sendMessage(inputnumber1.text)                }            }        }    }}

這個應用的設計非常簡單。我們的UI如下:




我們在上面的號碼輸入框中輸入自己想要撥打或傳送簡訊的號碼,按下“Call”或“Send Message”按鈕,就可以撥打到電話或傳送簡訊了。只不過簡訊或電話的應用被調用起來來完成這個動作。從安全的角度來說,這個需要使用者的互動才可以完成。對手機是非常安全的。我們使用了如下的代碼來完成url dispatcher的工作:

      function call(phonenumber) {            Qt.openUrlExternally("tel:///" + encodeURIComponent(phonenumber))        }        function sendMessage(phonenumber, text) {            Qt.openUrlExternally("message:///" + encodeURIComponent(phonenumber))        }


整個應用的完整代碼在如下的地址可以找到:

bzr branch lp:~liu-xiao-guo/debiantrial/phone



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.