得到ProximityKit KitUrl Android的JSON响应 [英] Get JSON response from ProximityKit KitUrl android

查看:207
本文介绍了得到ProximityKit KitUrl Android的JSON响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序概述:
1.注册为半径开发接近套件和创造栅栏。
2.获取从网站上下载的文件ProximityKit.properties从PKKitURL JSON响应。
3.解析JSON响应得到lat和长。获取用户的位置,并检查附近。

Overview of application: 1. Signup for Radius Developer's proximity kit and create Fences. 2. Get JSON response from PKKitURL in ProximityKit.properties file downloaded from website. 3. Parse JSON response to get lat and long. Get user's location and check for proximity.

目前,我已经做了签约,建立围栏,下载.properties文件,并到ProximityKit的SDK集成所需要的所有其他基本的东西。

Currently, i have done signing up, creating fences, downloading .properties file and all other basic things needed to integrate the ProximityKit's SDK.

现在我想从那个在属性文件present的URL JSON响应。我可以用下面的code检索URL。

Now I want to get the JSON response from the URL that's present in .properties file. I can retrieve the URL using the following code.

Configuration config = new Configuration(this);
Log.d(Const.DEBUG,
                "DeviceID = " + config.getDeviceId() + "\nKitUrl = "
                        + config.getKitUrl() + "\nLicenseKey = "
                        + config.getLicenseKey());

样JSON响应:

Sample JSON response:

{"kit":{"id":2837,"name":"My Kit","created_at":"2014-06-20T10:42:46.999Z","updated_at":"2014-06-20T10:42:46.999Z","links":{"map":"/api/maps/823"},"map":{"id":823,"name":"Wasp Hyderabad","created_at":"2014-06-20T16:20:13.504Z","updated_at":"2014-06-24T12:08:47.470Z","location":["17.4367","78.505243"],"overlays":[{"type":"circle","id":1968,"name":"Wasp Hyd Office","identifier":"pk-circleoverlay-1968","center":[17.443815,78.502657],"radius":197.846424},{"type":"circle","id":1969,"name":"Secunderabad","identifier":"pk-circleoverlay-1969","center":[17.437274,78.504884],"radius":257.538757}]},"ibeacons":[]}}

如果我直接尝试访问的网址,并得到响应,我得到一个AuthFailureError,我的猜测是因为一些认证问题。我的问题是我如何得到这个JSON回应我的应用程序?

If i directly try to access the url and get the response, i get a AuthFailureError, which i guess is because of some authentication issue. My issue is how do i get this JSON response to my application?

我把所有的属性文件所需要的参数,但我不知道,如何将它们发送到服务器,进行身份验证。任何人,谁一直在使用RadiusNetwork的ProximityKit能,帮助我。

I have all the required parameters in the .properties file, but i am not sure, how to send them to the server, to authenticate. Can anyone, who has been using RadiusNetwork's ProximityKit, help me out.

推荐答案

制作网页的URL请求不符合工作的支持方式ProximityKit 。使用 iBeaconDataUpdate 回调,并从提供的<读href=\"http://developer.radiusnetworks.com/ibeacon/android/pro/javadocs/com/radiusnetworks/ibeacon/IBeaconData.html\"相对=nofollow> IBeaconData 获得各种元数据。

Making a web URL request is not the supported way to work with ProximityKit. Use the iBeaconDataUpdate callback and read from the provided IBeaconData to get the various metadata.

例如,让说 welcomeMessage 的元数据:

public void iBeaconDataUpdate(IBeacon iBeacon, 
                              IBeaconData data, 
                              DataProviderException e) {
    if (iBeacon != null && data != null) {
        String displayString = iBeacon.getProximityUuid() + " " +
                iBeacon.getMajor() + " " + iBeacon.getMinor() + "\n" +
                "Welcome message:" + data.get("welcomeMessage");
        Log.d(TAG, "iBeacon Data: " + displayString);
    }
}

此外,要知道,ProximityKit会自动注册所有这些地区的为您服务。所以,你不必再告诉它需要开始监控它们的应用程序。

Also, be aware that ProximityKit will automatically register all of these regions for you. So you won't need to then tell the application it needs to start monitoring for them.

有关的ProximityKit API的更多信息,看看他们的Javadoc:<一href=\"http://developer.radiusnetworks.com/ibeacon/android/pro/javadocs/com/radiusnetworks/proximity/ProximityKitNotifier.html\" rel=\"nofollow\">http://developer.radiusnetworks.com/ibeacon/android/pro/javadocs/com/radiusnetworks/proximity/ProximityKitNotifier.html

For more information on the ProximityKit API have a look at their Javadocs: http://developer.radiusnetworks.com/ibeacon/android/pro/javadocs/com/radiusnetworks/proximity/ProximityKitNotifier.html

这篇关于得到ProximityKit KitUrl Android的JSON响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆