Create a new junaio Plugin project on Android

This section explains how to create a new project that uses junaio plugin.

Prerequisites

You should have an application identifier (package name) and your channel ID before proceeding. If not, please refer to Getting Started page on how to get these.

Creating the project

It is highly recommended that you start with JunaioPluginTemplate project to avoid lots of manual configurations. The following are steps to create a new project from junaioPluginTemplate:

1. Create copy of JunaioPluginTemplate . Click on the project name in the Package Explorer and copy/paste it. Eclipse will prompt for new project name and location:

Enter your desired name, e.g. JunaioPluginExample .

Make sure that your new project sources are not read-only before proceeding to next step.

2. Next, change the application package name to your application identifier. Right click on the project name, go to Android Tools->Rename Application Package. Then enter your package name and click OK. It will prompt to verify changes, remove POIDetailDialog and WebViewActivity from the list and click Finish and then YES to update launch configuration:

You are not done yet with package renaming, expand src under your project, and you can see that it still has com.metaio.junaio.plugin.template:

Click on it and press F2. It will prompt for new package name, enter your application package name you previously used, and press OK if you trust Eclipse. Check in the AndroidManifest .xml if the package name is now correct.

3. In order to change the name of the application go to res\values\strings.xml and chance the "app_name".

Congratulations, you have just created your first junaio plugin project.

Setting the channel

The new project created from template project would use default Wikipedia or junaio Glue Demo channel. You need to set your channel ID to view your contents.

The channel can be set in JunaioARViewTestActivity.onCreate method.

Note that if you channel is not yet public, you will need to additionally set authentication during junaio plugin initialization, i.e. see comments in JunaioStarterTask.doInBackground method.

Adding a custom GUI on top of camera preview

The template project adds a radar view on top of camera preview. However, you can add any custom GUI overlay. You need following:

  1. Create your custom GUI layout
  2. Inflate it in onCreate callback
  3. Add it by calling addContent method of the Activity in onStart callback

Note that it should always be added in onStart after calling super.onStart(), because camera view is added in onStart() method of JunaioARViewActivity.

The camera preview is always in landscape, so any custom GUI will always be in landscape mode. However, junaio plugin provide a custom layout to rotate the GUI to any orientation. This is explained below.

Reacting to the device orientation changes

The JunaioARViewActivity must always be in landscape orientation. This should be forced in AndroidManifest.xml of the project. If your application requires GUI to be in portrait mode, or automatically react to device orientation, you need following changes:

  1. Make com.junaio.plugin.view.RotatedLayout as root of your layout
  2. Call setOrientation with the desired orientation
  3. If it should react to device orientation, uncomment code in onOrientationSensorChanged method in JunaioARViewTestActivity

Adding the Radar View

The plugin provides a RadarView class which implements radar for AR view. The radar can be customized in the application by using any background image. To use radar view, you need following:

  1. Add com.junaio.plugin.view.RadarView view in your layout
  2. Set mRadar member of JunaioARViewActivity
  3. Set a background image. Note that the dots on the radar cannot be customized, so choose a background image that is in contrast with yellow dots.
Topic revision: r3 - 2012-03-20 - 11:03:33 - SupportMetaio
 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback