forked from Sunbird-Ed/SunbirdEd-mobile-app
-
Notifications
You must be signed in to change notification settings - Fork 7
/
MainActivity.java
45 lines (35 loc) · 1.12 KB
/
MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.sunbird.app;
import org.apache.cordova.CordovaActivity;
/**
* Created by swayangjit on 16/10/19.
*/
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
public class MainActivity extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// enable Cordova apps to be started in the background
Bundle extras = getIntent().getExtras();
if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {
moveTaskToBack(true);
}
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// Forward back key events to the web view.
if (this.appView != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
View webview = this.appView.getView();
if (webview != null) {
webview.dispatchKeyEvent(event);
}
return true;
}
return super.dispatchKeyEvent(event);
}
}