Xuni Android includes controls for Android java development. In this blog post I’ll walk you through getting started using Xuni Android from downloading to building an Android app.

  • Part 1: Get the Xuni Explorer App for Android
  • Part 2: Downloading and Running Samples
  • Part 3: Bookmark the Online the Documentation
  • Part 4: Adding Xuni Libraries to Your App (using Android Studio)
  • Part 5: Licensing Your App for Evaluation
  • Part 6: Working with Eclipse

Part 1: Get the Xuni Explorer App for Android

Before you download any libraries you can actually play with the Xuni Android controls yourself on your Android device. The Xuni Explorer app for Android explores every key feature for each Xuni control. The app lets you interact with the features. btn_store_google Next, when you’re ready to see some code you can download Xuni and run the samples.

Part 2: Downloading and Running Samples

Xuni Android libraries are distributed for both Eclipse and Android Studio development. When you download and install Xuni the packages gets installed to \Documents\Xuni\Android\Controls. The first thing you’ll probably want to do is build and run the samples.

Running Xuni Samples with Android Studio

Android Studio is the preferred IDE for new users and new Android development. You can very easily just open and run the Xuni samples for Android Studio installed at \Documents\Xuni\Android\Samples\Android Studio. We also have the sample code posted to GitHub. The Gradle scripts already reference the control libraries at the sample’s installed location. Use the following steps to run a sample such as Calendar101.

  1. In Android Studio, select File | Open
  2. Browse to \Documents\Xuni\Android\Samples\Android Studio and select Calendar101.
  3. Build the sample

Xuni-Android-Studio1 In Part 4 I will cover how to add a reference to Xuni libraries in your existing project.

Part 3: Bookmark the Online the Documentation

As you continue working with Xuni Android controls beyond this tutorial, you’ll undoubtedly need to check the documentation at some point. We’ve compiled user guides and reference API into a single, searchable set of docs you can bookmark here:

The documentation can also be found from the Resources menu of this website. You’ll notice that the Xuni Android documentation also includes code examples for C# which is for Xamarin.Android usage.

Part 4: Adding Xuni Libraries to Your App

When you’re ready to add Xuni libraries to your existing (or new) app, you can follow these steps.

  1. Open your app in Android Studio
  2. Select File | New | New Module
  3. Select Import .JAR or .AAR package Xuni-Android-New-Module
  4. Browse to /Documents/Xuni/Android/Controls
  5. Select a control library (.aar) you wish to add.
  6. For example, select xuni.core-XXX and you can rename it as just xuni.core.
  7. Repeat the process for each control library. Keep in mind of dependencies like Core (required for every library) and ChartCore (required for FlexChart and FlexPie).
  8. For example, select xuni.calendar-XXX
  9. Click Finish

The library has now been added to your project. Next, you need to update your Gradle.

  1. Open your application build.gradle file (Module: app)
  2. Add a line for each imported Xuni library like the following:

dependencies {  
    compile fileTree(dir: 'libs', include: ['*.jar'])  
    compile 'com.android.support:appcompat-v7:24.0.0-beta1'  
    compile project(':xuni.core')  
    compile project(':xuni.calendar')  

The app is now fully aware of the Xuni libraries. Next, you can add a control to some activity. For example, let’s define the XuniCalendar control in the main activity layout and then access it from code. Activity_main.xml example:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    xmlns:tools="http://schemas.android.com/tools" android:layout\_width="match\_parent"  
    android:layout\_height="match\_parent" android:paddingLeft="@dimen/activity\_horizontal\_margin"  
    android:paddingBottom="@dimen/activity\_vertical\_margin" tools:context=".MainActivity">  

        android:layout\_height="match\_parent" >  

MainActivity.java example: [java] protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_custom_appearance); XuniCalendar calendar = (XuniCalendar) findViewById(R.id.calendar1); calendar.setHeaderBackgroundColor(Color.rgb(61, 131, 75)); } [/java] Note that the minimum supported version of Android that Xuni can be used in is 4.0 (as of the time of this post). The minimum SDK supported can be found in the documentation.

Part 5: Licensing Your App for Evaluation

Licensing is a required step to evaluate or use Xuni controls within your own app. The Xuni controls contain runtime license validation per app. As I mentioned above, the samples already have a license key unique to that sample so they run “out of the box.” You can generate runtime keys on goxuni.com. To generate a runtime key for your app:

  1. Log in to www.goxuni.com. If you don’t have an account, you’ll need to create one. (It’s free.)
  2. Click Licensing Your App. This link can also be found in the Support menu. This page has more information and resources about licensing.
  3. Under Evaluation, click the link to generate a key.
  4. On the Generate a Key page, select Evaluation for the serial number.
  5. Select Java and enter the name of your app.
  6. Click generate.

Xuni-Android-Generate-Key Take this key and copy it into your project. The simplest way to do this is to create a new class, named License.java. The outputted text from the website includes the static class declaration so it’s very easy to just paste this into your editor. 7. Finally, in your code, before you initialize the Xuni control, set the Xuni.Core.LicenseManager.Key property to your key. [java] import com.grapecity.xuni.core.LicenseManager; ... LicenseManager.KEY = License.KEY; [/java] Now you should be up and running with Xuni in your Android app! When you purchase Xuni, you’ll get a serial number. Register that serial number on your My Account page, and when you generate new app keys, you’ll be able to select your serial number rather than selecting Evaluation.

Part 6: Working with Eclipse

If you prefer to still work with Eclipse, we have additional resources that will help. The documentation has a getting started tutorial, and we’ve produced a video that covers many of the topics covered above. https://vimeo.com/149910694 Thanks for reading and thanks for evaluating Xuni!