Tips & Topics

How to use the LG Friends Camera SDK - Part 1

The LG Friends developer event was held in both South Korea and the United States. The LG Friends Camera SDK, which is LG Friends first SDK, was announced at the event.

Unfortunately, the SDK session was too short to learn how to use it fully. To understand it better, let’s take a closer look at the SDK.


[LG Friends Developer Event]


Getting Started

The LG Friends Camera SDK supports “LG Friends Cameras” (obviously enough!). However, there is currently only one “LG Friends Camera” on the market.

If you’ve ever used LG 360 CAM, you know that it can connect to any smartphone, including LG smartphones, other Android smartphones and even iPhones (it’s amazing that LG Friends can play with other phones!).

LG 360 CAM works regardless of the platforms of the connected devices because it has adapted Google’s Open Spherical Camera (OSC).

As this site shows, OSC suggests common interfaces for 360-degree cameras that support Wi-Fi. Developers for 360 camera apps don’t need to update their app whenever a new 360-degree camera is launched.

LG 360 CAM supports all OSC APIs and other APIs unique to LG.


Open Spherical Camera API

OSC recommends using HTTP to connect the camera and smartphone. The camera needs to run a HTTP server to send and receive data through HTTP packets.



HTTP uses two methods to request server resources – GET and POST.

OSC uses both, but there is only one API using the GET method. Therefore, this article will focus on how to use the APIs with the POST method.




The above figure shows ‘/osc/commands/execute’ in the HTTP packet header. This is an OSC protocol that indicates what we are requesting the 360 CAM to do. The ‘/osc/commands/execute’ protocol lets the camera execute a command. It may be the most frequently used protocol in OSC.


The second line of the packet header contains the information about the HTTP server in the 360 CAM. The above figure shows the default IP address and the port number, which you can use in your app.

We need to describe additional information on the body of the packet. This example shows the command we want to request. The command is ‘camera.setOptions’. As its name suggests, the command sets options. So, the ‘parameter’ in the JSON data includes the detailed information about the options to set.


This is the basic function of OSC. Now, let’s talk about the LG 360 CAM development process.



Connection Process

LG provides two ways to connect the 360 CAM and a smartphone – the easy connection and the manual connection.

The former is used in LG Friends Manager. In this case, the app detects your 360 CAM through BLE and then turns on the SoftAP in your CAM to connect. All the user has to do is tap on the screen and follow the instructions. In this case, the 360 CAM uses both BLE and Wi-Fi.


The latter requires user involvement. First, turn on the SoftAP in the 360 CAM by double clicking the ‘Power’ and ‘Shoot’ buttons simultaneously. Then connect to the SoftAP in the Wi-Fi settings. As you may have guessed, BLE is not used here.

For example, we'll use this method in Street View.


LG Friends Camera SDK and the Library

The LG Friends Camera SDK currently supports Android and will support iOS soon. This article explains how to use the SDK in Android.

The SDK for Android provides the FriendsLink library so that everyone can implement the easy connection feature in their apps.



As the figure above shows, the OctopusApplication and ConnectionManager classes are essential.

Initializing – OctopusApplication

Your Application class must extend OctopusApplication. This enables your app to use BLE and Wi-Fi for easy connections.

The code is simple:


import com.lge.octopus.module.OctopusApplication;  
public class FriendsCameraApplication extends OctopusApplication {

Of course, you have to declare this Application class in the AndroidManifest.xml file as follows:


There is one more item to be added into AndroidManifest.xml. Adding atag allows your app to be installed only on devices that support BLE. However, this is optional.




Connecting – ConnectionManager

Now, connect the app to the 360 CAM using the ConnectionManager class.

All ConnectionManager methods are unsynchronized. Therefore, you need to register a BroadcastReceiver. All the filters you need are shown in the code block below.


IntentFilter scanFilter = new IntentFilter();


The first two are for BLE-related methods, while the others are for Wi-Fi-related methods.

Then, implement the BroadcastReceiver to handle the received intent actions and register it as a local broadcast receiver.

Central.PREIFX and WifiClicent.PREFIX represent the prefix of available action strings to enable easy filtering. The strings are included in the library. You can directly use the action strings instead of the constants.


private final BroadcastReceiver mUpdateReceiver = new BroadcastReceiver() {
    @Override    public void onReceive(Context context, Intent intent) {
        final String action = intent.getAction();

        if (action.startsWith(Central.PREFIX)) {
            // BLE handling
} else if (action.startsWith(WifiClient.PREFIX)) {
            // Wi-Fi handling
        } else {
            Log.e(TAG, "Error !! out of action");

// register local broadcast receiver
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(mUpdateReceiver, getFilter());


Next, create an activity and add a button. Tapping this button will scan the friends' devices by using StartScanFriends() in ConnectionManager. When it receives a response, mUpdateReceiver will handle it as implemented in the above code block.

The result of BLE scanning is given as a Central.ACTION_LE_SCANRESULT intent. You can retrieve and print the names of the devices as follows: 


// BLE scan resultif (Central.ACTION_LE_SCANRESULT.equals(action)) {
// get scanResult as  bundle    Bundle scanResult = intent.getExtras();
ScanResult foundDevice = new ScanResult(scanResult);
boolean isNew = mLeDeviceListAdapter.addDevice(foundDevice);
if(isNew) {


If the user wants to use one of the 360 CAMs on the list, call ConnectionManager.enableFriendsWithAp(). This method turns on the SoftAP in the 360 CAM. Once the SoftAP is turned on, connect it using ConnectionManager.connect().


See the following code:


if (selectedDevice.getWifiState() == Central.STATE.WIFI_ON) {
    // hotspot is already turned on    Log.d(TAG, "already hotspot on ");
    mConnectionManager.connect(getSsid(selectedDevice), getDefaultPassphrase());
} else if (selectedDevice.getWifiState() == Central.STATE.WIFI_OFF) {
    // try to enable friends wifi ap    Log.d(TAG, "Try to enable friends wifi ap");

The enableFriendsWithAp() method causes a Central.Action_FRIENDS_LE_RESULT intent. The connect() method causes a WifiClient.ACTION_FRIENDS_WIFI_RESULT intent.


All the intents used in the FriendsLink library are displayed the following table. 


connectionManager API Intent Description
StartScanFriends() Central.ACTION_LE_SCANRESULT Intent is broadcasted each time a new device is found after starting device scan
StopScanFriends() - No Intents are broadcasted
enableFriendWifiAp(String address) Central.ACTION_FRIENDS_LE_RESULT The result of GATT request to the server is returned in the Intent
connect(String ssid, String passwd) WifiClient.ACTION_FRIENDS_WIFI_RESULT The result of Wi-Fi connection request with the specified SSID is returned in the Intent
disconnect() WifiClient.ACTION_WIFI_STATE The Wi-Fi connection state (connected/disconnected) of the Friends device is returned in the Intent
isConnected(String ssid) - No Intents are broadcasted. The method itself returns a boolean value indicating the Wi-Fi connection state.


Once the connection has been made, you can control the 360 CAM with OSC APIs. This requires sending HTTP packets that include the OSC APIs. The sample app for the LG Friends Camera SDK shows how to send HTTP packets in Android.


The detailed description will be continued in the next post.