6 package com.google.appinventor.components.runtime;
8 import android.app.Activity;
10 import android.content.Context;
11 import android.content.Intent;
12 import android.content.pm.PackageInfo;
13 import android.content.pm.PackageManager;
14 import android.content.pm.PackageManager.NameNotFoundException;
16 import android.net.Uri;
18 import android.os.Bundle;
19 import android.os.Handler;
21 import android.util.Log;
23 import android.webkit.JavascriptInterface;
24 import android.webkit.WebChromeClient;
25 import android.webkit.WebSettings;
26 import android.webkit.WebStorage;
27 import android.webkit.WebView;
28 import android.webkit.WebViewClient;
30 import androidx.core.app.ActivityCompat;
31 import androidx.core.content.ContextCompat;
56 }
else if (ContextCompat.checkSelfPermission(mContext, permission) ==
57 PackageManager.PERMISSION_GRANTED) {
67 new String[] { permission}, 1);
73 String packageName = mContext.getPackageName();
74 PackageInfo pInfo = mContext.getPackageManager().getPackageInfo(packageName, 0);
75 return (pInfo.versionName);
76 }
catch (NameNotFoundException e) {
94 public void onCreate(Bundle savedInstanceState) {
95 super.onCreate(savedInstanceState);
97 handler =
new Handler();
98 webview =
new WebView(
this);
99 WebSettings webSettings = webview.getSettings();
100 webSettings.setJavaScriptEnabled(
true);
101 webSettings.setDatabaseEnabled(
true);
102 webSettings.setDomStorageEnabled(
true);
103 String databasePath = this.getApplicationContext().getDir(
"database", Context.MODE_PRIVATE).getPath();
104 webSettings.setDatabasePath(databasePath);
124 webview.setWebChromeClient(
new WebChromeClient() {
126 public void onExceededDatabaseQuota(String url, String databaseIdentifier,
127 long currentQuota,
long estimatedSize,
long totalUsedQuota,
128 WebStorage.QuotaUpdater quotaUpdater) {
129 quotaUpdater.updateQuota(5 * 1024 * 1024);
137 webview.addJavascriptInterface(android,
"Android");
138 webview.loadUrl(
"file:///android_asset/splash.html");
143 String permissions[],
int[] grantResults) {
144 for (
int i = 0; i < permissions.length; i++ ) {
145 String permission = permissions[i];
146 int grantResult = grantResults[i];
147 boolean granted =
false;
148 if (grantResult == PackageManager.PERMISSION_GRANTED) {
151 webview.loadUrl(
"javascript:permresult('" + permission +
"'," + granted +
")");