Resources

MY CLOUD HOME

USEFUL TIPS

My Cloud Home Device SDK provides simple and secure APIs to help you build your app as per your requirements. This section provides some useful tips when integrating your app with My Cloud Home.

Data Storage

There are two types of storage in the My Cloud Home Device: Application storage and User Content storage. 

  • Application Storage

    Application Storage is available for the apps to store app-specific data such as user details, app status, and app states. Usually, this information is stored in SharedPreference or the database. This application storage is exclusive for the application, and only you can see this content. Ensure that your app does not store a massive amount of data in SharedPreference or the Database as it has limited storage.

  • User Content Storage

    User Content Storage is available for users to store their content. In Android mobile/tablet, this is an internal or external SD card storage where files such as camera photos, music, and downloads are stored. SD Card storage is public to all apps, and anyone who has permission declared in their manifest file can get access to it.

    In My Cloud Home app, all user content MUST be stored under User Content storage space. Use MyCloudUIServer.getRootFolder() to find the root folder for the given user. Similar to an Android’s external SD card, content in this space is visible to all apps, which the user can access.

Android Service Restart

Android can kill a service in an unlikely event of memory crunch. You can use the following options to make sure service-restart is handled correctly.

  • Using START_STICKY to restart the service when sufficient memory is available. 
  • Using StartServiceAt to schedule a service to run at a specific time. When the service is started, you can schedule the next one. This way you can create a service that runs every x minutes or hours.

Ensure to store all the required information to restart the service.

 

App Upgrade

The application upgrade is automatic on My Cloud Home ecosystem. The device does a silent upgrade of the app if a new version is available in the app catalog. However, you should handle tasks like data migration in the app upgrade. Standard Android SQLiteOpenHelper onCreate() and onUpgrade() will work as is in the device.


Reliability

Reliability is a “must have” for the My Cloud Home device apps. On-device apps follow the "fire and forget" method of operation. Once configured the apps run reliably in the background without any user intervention. After initiating the tasks, the users do not interact with the app for constant updates. You should ensure that the app recovers and works reliably in the background even after a Crash or Force Close Error.

 

Threads and Services

Spawning too many threads and services and can take the My Cloud Home device to a busy state and affect performance. On-device apps should run reliably and silently in the background.

 

Navigating between multiple HTML pages

If you want to navigate to different pages from your landing page, you can use relative paths and can identify the request in your get method. You can get the requesting URL in your get method using session.getUri().

String uri = session.getUri()
// You can also do some url checks to see which page is requested by the user. For example,

if (uri.endsWith("/user/")) {
    //get html content for user.html
}
// or
if (uri.equals("/signin")) {
    //get html content for signin.html
}

HTTP Post Handling

If your web application is making a post-call with a query parameter, then you can get it using session.getParms().

For example, session.getParms().get("user_name").

If your web application is making an HTML form post action, then here is some sample code to help you with it.

<form action="http://localhost:3388" method="POST">
    <input type="text" name="username" value="UserNameOne">
    <input type="submit">
</form>

@Override
public Response post(IHTTPSession ihttpSession) {
    try{
        Map files = new HashMap();
        ihttpSession.parseBody(files);
        String postBody = ihttpSession.getQueryParameterString();
        Log.d(TAG, "##### Post Body:" + postBody);
        }catch (Exception e) {
        Log.d(TAG, "##### POST handling exception " + e.getMessage());
        return newFixedLengthResponse("<h1>Sorry, folder creation failed.</h1>

");
    }
    return newFixedLengthResponse("<h1>Post message successfully received.</h1>

");
}

 

Sending Notification to User

Your app may want to communicate some important messages to its users. For example, if the account credential that the user configured with My Cloud Home has changed, or there is not enough space available for the app to perform a specific operation, then your app may want to communicate this to the user. However, the UI part of the My Cloud Home app is not visible to the user at all times and can be accessed only through web pages. 

My Cloud Home Device SDK provides an option for the app to communicate messages using the My Cloud Home notification system. The notification message is delivered to the user through push notification (in case of a mobile device) and email messages.

Use com.wdc.nassdk.Utils.sendPushNotification()to send a notification. The complete method signature is shown in the example below.

public static void sendPushNotification(final String myCloudId, 
final String notificationTitle, final String notificationContent, final String locale)

Example

Utils.sendPushNotification(myCloudUserID, "Sample App Notification", 
"This is a sample app notification from MyCloud", "en");

Do more with the
My Cloud Home On-Device SDK

Click the buttons below to visit the My Cloud Home On-Device Developer Home & Workflow pages

 

Developer
Home

Get started, access the SDK, build your apps, & learn more


View Home

Developer
Workflow

Register & submit your app for review and contact support


View Workflow