Using the LG G3 Circle Case SDK to Create a Demo Application

What is the Circle Case?

LG offers a unique accessory for its G3 model—a special case with several advanced features. This case supports NFC technology, wireless charging via the Qi standard (available in the European market), and includes a circular cutout on the front cover. This circular window allows users to interact with about one-third of the display using a customized GUI, providing quick access to certain apps and functions.

LG G3 SDK

To help developers leverage the circle case's features, LG released a lightweight SDK. The core functionality revolves around detecting the opening and closing of the case using a hidden magnet within the case and a sensor behind the screen. The SDK provides a broadcast receiver to capture these events.

Here's a basic example of how you can use this in your app:       

public class QCircleActivity extends Activity {

 // [START]declared in LGIntent.java of LG Framework
 public static final int EXTRA_ACCESSORY_COVER_OPENED = 0;
 public static final int EXTRA_ACCESSORY_COVER_CLOSED = 1;
 public static final String EXTRA_ACCESSORY_COVER_STATE = "com.lge.intent.extra.ACCESSORY_COVER_STATE";
  public static final String ACTI;

       // . . .

        private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
  @Override
  public void onReceive(Context context, Intent intent) {  

   //Receives a LG QCirle intent for the cover event
   if (ACTION_ACCESSORY_COVER_EVENT.equals(action)) {

    //Gets the current state of the cover
    mQuickCoverState = intent.getIntExtra(EXTRA_ACCESSORY_COVER_STATE,
      EXTRA_ACCESSORY_COVER_OPENED);

    if (mQuickCoverState == EXTRA_ACCESSORY_COVER_CLOSED) { // closed
     //Set window flags
     setQuickCircleWindowParam();
    } 
    else if (mQuickCoverState == EXTRA_ACCESSORY_COVER_OPENED) { // opened
      //Call FullScreenActivity
      Intent callFullscreen = new Intent(mContext, FullScreenActivity.class);
      startActivity(callFullscreen);
      
      //Finish QCircleActivity
      QCircleActivity.this.finish();
    }
   }
  }
 };

       // . . .
}


Customizing the GUI

For the graphical interface, you can use all standard layout widgets. However, only the portion of the layout visible through the circular cutout will be displayed to the user. You can address this by setting precise margin values to ensure your content fits within the circle.

Here's an example layout:

       


<RelativeLayout 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:layout_gravity="top|center_horizontal"
    android:background="#000000">

    <RelativeLayout
        android:id="@+id/cover_main_view"
        android:layout_width="@dimen/physical_width_of_quickcircle"
        android:layout_height="@dimen/physical_height_of_quickcircle"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/background">

        <!-- ... -->
    >/RelativeLayout<

</RelativeLayout>



Results of Testing

To experiment with the circle case feature, I decided to develop a quick game. The game utilizes the phone's accelerometer for control and the vibration feature for feedback. To manage game scores, I used Sugar ORM.

The objective of the game is simple: navigate a spaceship through as many gates as possible. With each gate passed, the game speeds up, increasing the challenge. Players tilt the device to control the rocket’s movement, making for an engaging and interactive experience.

I also published the game on the Google Play Store, and you can check out some screenshots below.

You can find the source code here: 



Comments

Popular posts from this blog

Skate Tricks Recognition Using Gyroscope

Play table

Counting dice and train wagons using computer vision