Created
September 15, 2011 14:48
-
-
Save ber4444/1219438 to your computer and use it in GitHub Desktop.
Usage of LayarPlayer library (SDK) for BlackBerry 7 -- how to add augmented reality to your app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright 2011 Layar BV. All rights reserved. | |
* Support: http://devsupport.layar.com | |
* By implementing the LayarPlayer in your application, you agree to the Terms and Conditions | |
* described in the Layar_Software_Development_Kit_License_Agreement.pdf file which can be found | |
* in the LayarPlayer SDK zip file. | |
*/ | |
package com.test.ARdemo; | |
import java.util.Hashtable; | |
import net.rim.device.api.ui.Field; | |
import net.rim.device.api.ui.FieldChangeListener; | |
import net.rim.device.api.ui.UiApplication; | |
import net.rim.device.api.ui.XYEdges; | |
import net.rim.device.api.ui.component.ButtonField; | |
import net.rim.device.api.ui.component.EditField; | |
import net.rim.device.api.ui.component.LabelField; | |
import net.rim.device.api.ui.container.MainScreen; | |
import net.rim.device.api.ui.decor.BorderFactory; | |
public class ARdemo extends UiApplication { | |
public static void main(String[] args) { | |
ARdemo theApp = new ARdemo(); | |
theApp.enterEventDispatcher(); | |
} | |
public ARdemo() { | |
pushScreen(new ARview()); | |
} | |
} | |
final class ARview extends MainScreen { | |
public final static int LIST_VIEW_ENABLED = 1; | |
public final static int MAP_VIEW_ENABLED = 2; | |
public final static String RADIUS = "radius"; | |
public final static String RADIOLIST = "RADIOLIST"; | |
public final static String CHECKBOXLIST = "CHECKBOXLIST"; | |
public final static String CUSTOM_SLIDER = "CUSTOM_SLIDER"; | |
public final static String SEARCHBOX = "SEARCHBOX"; | |
public final static String OAUTH_KEY = "oauth_consumer_key"; | |
public final static String OAUTH_SECRET = "oauth_consumer_secret"; | |
ARview() { | |
add(new LabelField("Layer name:")); | |
final EditField edit = new EditField(USE_ALL_WIDTH); | |
edit.setBorder(BorderFactory.createSimpleBorder(new XYEdges(1, 1, 1, 1))); | |
add(edit); | |
ButtonField button = new ButtonField("Show me!"); | |
button.setChangeListener(new FieldChangeListener() { | |
public void fieldChanged(Field field, int context) { | |
/** | |
* LayarPlayer parameters: | |
* @param layerName | |
* @param oauthParameters - Hashtable; required keys: OAUTH_KEY & OAUTH_SECRET | |
* @param layerFilters - Hashtable; supported keys: | |
* RADIUS, RADIOLIST, CHECKBOXLIST, CUSTOM_SLIDER, SEARCHBOX. | |
* If there is more then one SEARCHBOX, use the keys SEARCHBOX_1, SEARCHBOX_2, etc. | |
* The same applies to CUSTOM_SLIDER. | |
* @param options - (int), combination of view options bits (0, 1, 2, 3). | |
* 0 - Disable both Map and List view only | |
* LIST_VIEW_ENABLED | MAP_VIEW_ENABLED - Enable all views. | |
*/ | |
Hashtable oauthParams = new Hashtable(); | |
oauthParams.put(OAUTH_KEY, "xxx"); | |
oauthParams.put(OAUTH_SECRET, "xxx"); | |
com.layar.player.LayarPlayerController.loadLayerWithName(edit.getText(), oauthParams, | |
null, LIST_VIEW_ENABLED | MAP_VIEW_ENABLED); | |
} | |
}); | |
add(button); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment