Why Webview freezes the Emulator with Gif immage? - android

I am using HTML content (which is a gif image) to be viewed in a Webview. WEbview is successfully loaded the HTML content and the Gif image appeard. But, after some time the Emulator freezed and it stopped responses. Thanks in advance for any help.
public class ABC extends AppCompatActivity {
WebView webview;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.abc);
webview=(WebView)findViewById(R.id.webview) ;
webview.loadUrl("file:///android_asset/hayder.html");
}
}

android manifest add this
<application
...
android:hardwareAccelerated="true"
...
>

Related

How can I put a map that was created in Google Maps in my application?

I created a map with Google Maps that has symbols on it : https://www.google.com/maps/d/u/0/viewer?mid=1IOw_y51yt8YaQeTzgRvoEhn5drk&ll=32.11239510425183%2C34.80320922355645&z=17
I would like to put this map in my android application, is there a way to do so? everything I saw online was to create a map and add markers, but if I already have a map how can I put it?
You can make a WebView in your Layout, and just load the url in it.
public class Main extends Activity {
private WebView mWebview;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mWebview = new WebView(this);
mWebview.loadUrl("https://www.google.com/maps/d/u/0/viewer?mid=1IOw_y51yt8YaQeTzgRvoEhn5drk&ll=32.11239510425183%2C34.80320922355645&z=17");
setContentView(mWebview);
}
}

Displaying html file in webview on android lollipop device giving unformatted text

I want to display a html file from a URL into a webview
If i run the app on a device running pre-lollipop (4.2)the html file is displayed as desired like below
But if i run the app on a device running lollipop (5.1)its showing unformatted text in webview like below
Why does this happen ?
mainactivity
public class MainActivity extends Activity
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String webViewurl = "http://files.parsetfss.com/f1c96efa-83e3-4dc3-8e0e-7c5b6dbbd7a2/tfss-7862469c-fb9d-4e9e-b914-779fd8415e13-main.html";
WebView wv = (WebView) findViewById(R.id.mainWebView);
wv.loadUrl(webViewurl);
}
}

WebView - Want to open in app not in browser

I have a problem. I created some app, which should open my website, but when I run the app on my phone, its ask me in which browser I want to open it(Google Chrome...). But I want that website is open in app, not in browser... I'm working with Android Studio 1.1.0... Here is my code in MainActivity.java:
public class MainActivity extends ActionBarActivity {
private WebView MyWeb;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MyWeb = (WebView) findViewById(R.id.WebView);
MyWeb.getSettings().setJavaScriptEnabled(true);
MyWeb.getSettings().setSaveFormData(true);
MyWeb.loadUrl("http://www.mywebsite.com");
} }
P.S. I changed the url to the fake one...
Add this line of code before your MyWeb.loadUrl
MyWeb.setWebViewClient(new WebViewClient());
This worked for me.!

Android prob to show pdf in webview

I am using android Webview to load a url to show a pdf file.
Here is my code:
public class TestProgectActivity extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView mtWebView=new WebView(this);
setContentView(mtWebView);
mtWebView.getSettings().setJavaScriptEnabled(true);
mtWebView.loadUrl("https://docs.google.com/viewer?url=http://www.cbwe.gov.in/HTMLEditor1/pdf/sample.pdf");
}
}
It is working for the link "https://docs.google.com/viewer?url=http://www.cbwe.gov.in/HTMLEditor1/pdf/sample.pdf".
But it is not working for "https://docs.google.com/viewer?url=http://www.pancreaze.net/pdf/PANCREAZE.pdf". When I am firing this url through Webview it is showing HTML content in the WebView instead of the actual pdf file. Here is the screenshot.
What is problem in my code?

Image from WebView

i m getting a photo from the web,but i see it very large..how could i see it with zoom out?this is my code for webView:
public class gavros extends Activity {
WebView browser;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.efimerides);
browser =(WebView)findViewById(R.id.webview);
browser.loadUrl("http://...");
}}
Checkout WebView's setInitialScale method:
http://developer.android.com/reference/android/webkit/WebView.html#setInitialScale(int)

Categories

Resources