- add sources.
[platform/framework/web/crosswalk.git] / src / mojo / shell / android / apk / src / org / chromium / mojo_shell_apk / MojoShellActivity.java
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.mojo_shell_apk;
6
7 import android.app.Activity;
8 import android.content.Intent;
9 import android.os.Bundle;
10 import android.util.Log;
11
12 import org.chromium.mojo_shell_apk.LibraryLoader;
13 import org.chromium.mojo_shell_apk.MojoMain;
14
15 /**
16  * Activity for managing the Mojo Shell.
17  */
18 public class MojoShellActivity extends Activity {
19     private static final String TAG = "MojoShellActivity";
20
21     @Override
22     protected void onCreate(final Bundle savedInstanceState) {
23         super.onCreate(savedInstanceState);
24
25         try {
26             LibraryLoader.ensureInitialized();
27         } catch (UnsatisfiedLinkError e) {
28             Log.e(TAG, "libmojo_shell initialization failed.", e);
29             finish();
30             return;
31         }
32
33         MojoMain.init(this);
34
35         String appUrl = getUrlFromIntent(getIntent());
36         MojoMain.start(this, appUrl);
37         Log.i(TAG, "Mojo started: " + appUrl);
38     }
39
40     private static String getUrlFromIntent(Intent intent) {
41         return intent != null ? intent.getDataString() : null;
42     }
43 }