Reputation: 1449
I am developing an android application which requires to open url link in web browser with zoom in and zoom out control (i.e, Chrome)
For Zoom in and zoom out facility i found one solution but i want to set zoom in and zoom out functionality programmatically.
I do not want to use android WebView for load webpages.
try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.mds-foundation.org/mdsmanager/help"));
startActivity(myIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(MainActivity.this, "No application can handle this request. Please install a web browser", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
Upvotes: 0
Views: 1280
Reputation: 665
If you do not want to Android Webview for open url, Then you can set chrome custom tab for opening Url in your application.
Upvotes: 1
Reputation: 1082
You cannot set zoom level while using the intent Intent.ACTION_VIEW. The solution that you are referring is handling zoom level inside the App only. This is not possible with firing intent.
If you want to use Android WebView then you can do it like this
public class MyBrowser extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_layout);
String loadUrl = "https://stackoverflow.com/";
int scale = 60; //scale is percent of zoom level you want
WebView webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setInitialScale(scale);
try {
webView.loadUrl(loadUrl);
} catch (Exception e) {
e.printStackTrace();
}
}
}
in your layout file you can define the webview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"></WebView>
</LinearLayout>
Upvotes: 0