如何获得共享Glympse链接?

时间:2016-12-14 11:45:43

标签: android glympse

我必须使用Glympse实现实时跟踪。在Glympse应用程序中,您可以共享链接以显示您当前的位置。现在我必须得到该链接并将该链接发送到服务器。我正在寻找它,但我无法获得所需的解决方案来获得该链接。

我有https://developer.glympse.com/docs/core/client-sdk/downloads链接的示例。

1 个答案:

答案 0 :(得分:0)

GlympseCreateDemo显示了获取链接所需的步骤,但以下是关键部分。

// Create the ticket for the given duration.
GTicket ticket = GlympseFactory.createTicket(duration, null, null);

// For the recipient list, we create a single "LINK" recipient. This
// means we want a recipient URL for the new Glympse without having
// the Glympse API actually send the invite out to anyone.
GInvite recipient = GlympseFactory.createInvite(GC.INVITE_TYPE_LINK, null, null);
ticket.addInvite(recipient);

// Call sendTicket to create the ticket and the recipient URL.
_glympse.sendTicket(ticket);

收听链接何时可用

// The object you pass to this method must implement GEventListener
// In the demo this is done in GlympseCreateDemoActivity.java
ticket.addListener(this);

// Once the invite is ready you will get this event
@Override public void eventsOccurred(GGlympse glympse, int listener, int events, Object obj)
{
    if (GE.LISTENER_TICKET == listener)
    {
        if (0 != (events & GE.TICKET_INVITE_CREATED))
        {
            GTicket ticket = (GTicket) obj;
            // This string will contain the link that you can send to your server
            String theUrlLink = ticket.getInvites().at(0).getUrl();
        }
    }
}