【问题标题】:BlackBerry 10 Cascades: How to invoke Contacts with prefilled fields?BlackBerry 10 Cascades:如何使用预填充字段调用联系人?
【发布时间】:2013-07-11 14:09:34
【问题描述】:

正如标题所说,我正在尝试在 BlackBerry Cascades 中调用联系人:

https://developer.blackberry.com/cascades/documentation/device_platform/invocation/contacts.html

使用包含 vCard 的字符串变量填充的字段。我对上述文档中指定的 mimeTypes、URI、操作和目标没有成功。以下代码或我可以从记录的案例中开发的任何变体都不会调用:

    Container {
    property string inputString //contains data from which vCard should be extracted if detected
    //....
    attachedObjects: [
            Invocation {
                id: myQuery
                property bool ready: false
                query {
                    mimeType: "text/plain"
                    invokeTargetId: "sys.browser"
                    uri: ("http://www.google.com/search?q="+ escape(inputString))
                    invokeActionId: "bb.action.OPEN"
                    data: ""
                    onArmed: {myQuery.ready = true}
                    onQueryChanged: {
                        myQuery.query.updateQuery()
                    }
                }
        }
    //....
     if (inputString.indexOf("VCARD") > -1) {
            myInvocation.query.setMimeType("");
            myInvocation.query.setUri(inputString);
            myInvocation.query.setData(inputString);
            myInvocation.query.setInvokeTargetId("sys.pim.contacts.card.viewer");
            myInvocation.query.setInvokeActionId("bb.action.VIEW");
            myInvocation.query.updateQuery();
    }
     //...
     Button {
     onClicked: {
                if (myQuery.ready = true) {
                    myQuery.trigger(myQuery.query.invokeActionId);
                }

            }
            }
      }

其他调用(如 SMS、电子邮件和浏览器)确实使用此设置调用,尽管 MimeType、URI、数据、目标和操作需要一些摆弄才能正确设置,并且最终起作用的配置不是文档中的配置。

那么,如何调用联系人呢?

【问题讨论】:

    标签: blackberry-10


    【解决方案1】:

    我已经修改了您的代码,因此您现在可以将浏览器应用程序(如您提供的代码中)作为联系人应用程序启动。我的开发设备上没有设置任何联系人,因此要查看某个联系人,您需要提供相应的联系人 ID(有关此信息,请参阅 ContactService)等等

    import bb.cascades 1.0
    
    Page {
        Container {
            property string inputString //contains data from which vCard should be extracted if detected
            //....
    
            Button {
                text: "..."
                onClicked: {
                    myQuery.trigger(myQuery.query.invokeActionId);  // launches browser
                    contactInvocation.trigger(contactInvocation.query.invokeActionId);  // launches contacts
                }
            }
            attachedObjects: [
                Invocation {
                    id: myQuery
                    query {
                        mimeType: "text/plain"
                        invokeTargetId: "sys.browser"
                        uri: ("http://www.google.com/search?q=" + escape("sample"))
                        invokeActionId: "bb.action.OPEN"
                        onQueryChanged: {
                            myQuery.query.updateQuery()
                        }
                    }
                },
                Invocation {
                    id: contactInvocation
                    query {
                        invokeTargetId: "sys.pim.contacts.app"
                        mimeType: "application/vnd.blackberry.contact.id"
                        invokeActionId: "bb.action.OPEN"
                        onQueryChanged: {
                            contactInvocation.query.updateQuery()
                        }
                    }
                }
            ]
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-11-06
      • 2011-12-31
      • 1970-01-01
      • 2019-10-21
      • 2021-12-10
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多