Settings Activity

The NEON API provides access to a Settings Activity that allows the end user to configure several different parameters of the NEON Location Service. The Settings Activity allows the user to:

  • Change the associated NEON account
  • Pair and select a NEON Tracking Unit
  • Check for NEON Location Service updates
  • Check for NEON Tracking Unit firmware updates
  • Read the NEON End User Agreement

Below are a set of steps to add the Settings Activity to your app.

Add Settings Menu

One way to bring up the NEON Settings Activity is to create a menu with an item that opens the NEON Settings Activity. You will need to add a menu folder to the res directory in your module if you don’t already have one. You can do this by right clicking on the res folder, selecting New->Android Resource Directory, and choosing the resource type of Menu. Then, right-click on the menu resource directory and add a new resource file with New->Menu resource file called main.xml.

The code below shows a simple menu with one option called “Settings.”

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:id="@+id/action_settings"
        android:checkable="false"
        android:enabled="true"
        android:icon="@android:drawable/ic_menu_preferences"
        android:orderInCategory="100"
        android:title="Settings"
        android:visible="true" />
    
</menu>

Next, add the following lines to your Activity to create the options menu and handle an item being presses.

/**
  * Sets up options, gets the menuitems to allow for efficient visibility changes
  */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

/**
  * Set up the action bar with standard tasks and actions from user interface
  * settings: navigate to NeonLocationService settings page
  */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    switch (id) {
        case R.id.action_settings:
            Intent settingsIntent = new Intent(Neon.ACTIVITY_SETTINGS);
            startActivity(settingsIntent);
            return true;
    }

    return super.onOptionsItemSelected(item);
}

Calling startActivity(new Intent(Neon.ACTIVITY_SETTINGS)) will bring up the NEON Settings Activity.

Display Action Bar

To display a top action bar, change the Activity to extend AppCompatActivity instead of FragmentActivity and add the following lines to your onCreate().

if (getSupportActionBar() != null) {
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().show();
}

View Settings Activity

When you run this app, you should see an action bar on the top of the screen with three dots on the right. Click the three dots and select “Settings” to access the NEON Location Service Menu.

Settings Activity