Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Moved to Android Development forum.
You problem isn't clearly defined. Could you clarify, and add some relevant code to demonstrate the problem?
private WebView webview;
String url = "https://SOME-URL.com/";
ProgressBar progress;
@Override
@SuppressWarnings("setJavaScriptEnabled")
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
Toolbar toolbar = findViewById(R.id.mytoolbar);
toolbar.setTitleTextAppearance(this, R.style.toolbarText);
setSupportActionBar(toolbar);
if(getSupportActionBar() != null){
getSupportActionBar().setElevation(4);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
progress = findViewById(R.id.progressBar);
progress.setVisibility(View.GONE);
webview = findViewById(R.id.webView);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setDisplayZoomControls(false);
webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
webview.setWebViewClient(new MyWebViewClient());
webview.loadUrl(url);
webview.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url,
String userAgent,
String contentDisposition,
String mimetype,
long contentLength) {
String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype);
String cookie = CookieManager.getInstance().getCookie(url);
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setAllowedOverRoaming(false);
request.allowScanningByMediaScanner();
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
request.addRequestHeader("Cookie", cookie);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
if (dm != null) {
dm.enqueue(request);
}
}
});
}
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
progress.setVisibility(View.VISIBLE);
Stylo.this.progress.setProgress(0);
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
progress.setVisibility(View.GONE);
Stylo.this.progress.setProgress(100);
super.onPageFinished(view, url);
}
}
@Override
public void onBackPressed() {
if(webview.canGoBack()) {
webview.goBack();
} else {
super.onBackPressed();
}
}
i don't any problem in coding
just For example, I open my site with a browser, similar to Chrome.
I can browse and send post on the site
. But in webview app, I can not access the site's internal content, such as uploading or ...
But the problem here is with internal content like file uploads, likes, comments and ...Can not access
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto"
package="ir.picsgram.usershots">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name=".WebViewAppApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.WebViewApp.Gray"
android:hardwareAccelerated="true"
android:allowBackup="true"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
tools:ignore="AllowBackup,UnusedAttribute">
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name"
android:launchMode="standard"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="@string/app_deep_link_host" />
<data android:pathPrefix="@string/app_deep_link_path" />
</intent-filter>
</activity>
</application>
</manifest>
my first problem is not installing app
When you say "not installing", what's the problem? Do you get an error? What happens when you try to install it directly from Android Studio?
What error is in the Logcat?