In phone gap html page take too much time to load - android

Hi I am making application using phone gap in which certain html pages in asset folder of project. and I am using the code below. but it takes too much time in loading.
can any one give proper solution ?
Thanks!
public class JvdActivity extends DroidGap {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.init();
KeyBoard keyboard = new KeyBoard(this, appView);
appView.addJavascriptInterface(keyboard, "KeyBoard");
super.loadUrl("file:///android_asset/www/index.html");
}
}

If their are lots Images inside the HTML page then to load that page Inside the screen It takes Time.
But if it is requirement of your project then you will use progress bar saying Loading.. so that user can wait till the page gets loaded.

Related

Android DatePicker is so slow in WebView

Below is the WebView code, which shows the webpage at here. Everything works fine. The date picker is so slow, everything else works fine. It takes like 4-5 seconds to select a date. Any alternatives?
public class click extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.click);
WebView webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.exceptnothing.com/appointment.html");
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
}
}
I tried adding android:hardwareAccelerated="true" in that activity, same effect still.
I'm a beginner, so simpler code will be appreciated. Thanks in advance :)
try to checkout android DatePickerDialog. Its native and fast way to pick a date on android. Also, using webview in android applications is a bad practice to build a well formed user interfaces, it's realy decreases the application performance, look, and user feel. Native android vidgets are always best to do the work. This tutorial will help you if you decide to build your ui as views layout http://www.tutorialspoint.com/android/android_datepicker_control.htm

Eclipse Android App Zoom In Code WebView

I'm very new to developing android apps. I've edited this app I found, which was open source and have got it working to a good extent. There's some code that isn't being used at all (Like the preferences menu) but I haven't removed that as I simply don't want to mess it up. Anyway, when I view the website it's zoomed in.. I've researched the problem and found a few ways to fix it, but none have worked. The app files can be downloaded at this link: http://www.megafileupload.com/en/file/504860/App-zip.html
Thanks for any help!
Now, here's where the answer comes in.
You get the settings for your webview before you instantiate it. You need something like:
void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard); // do this first
WebView webView = (WebView) findViewById(R.id.yourwebviewid); // either this or
either the above to tie the Java object to an xml object
or create a view and add it to some parent
View parent = (View)findViewById(R.id.yourparent_layout_for_webview); // this
WebView webView = new WebView();
parent.add(webView);
webView.getSettings().setBuiltInZoomControls(true);

Creating a Questionnaire in Android

Peace be on all of you!
I have to develop a questionnaire like small android app. There will be 10 questions with only 2 types of answers, i.e. either "Yes" or "No". When the user will answer all of the 10 questions, a report will be shown to user according to his answers.
Kindly tell me, how should I proceed? Do I need to use database (sqlite) or can work without it? and how should I start to develop this app?
I am new to Android.
Thank-you!
If you are new to Android, than use a web approach: Show a html page 1-10 in a webView and link it each other and finally the 10th is linked to an url, where you will do a http POST / GET with your collected 10 params. Exactly as how would you do in a "standard' web development. Also you can use several app to wrapp into Android app: Appcelerator, Phonegap and so on.
Here is a class which is a screen: (Android Activity)
public class Help extends Activity{
private WebView webViewHelp;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
webViewHelp = (WebView) findViewById(R.id.webViewHelp);
webViewHelp.loadUrl("file:///android_asset/ui/help.html");
}
}
you need the help.xml build and placed into /res/layout/ folder.
Also write the help.html and place it into: /assets/ui folder and not android_asset and at is not file:///assets/ui/help.html!
in this case you have the starting point set up, than go and load with html links the next next next ... until is done, than pust url.
Somewhat easyer if you are doing in android ui development, and not web-like, but that need a bit more experience

LoadUrl in PhoneGap and Android

I am working on an app for android using phonegap and unity.
I wrote a plugin for phonegap that starts a new activity from phonegap that loads the unity player. When i hit the back button in the unity activity i want to go back to the phonegap activity and load my webcontainer again, but with a different url.
Whatever i try, it still loads the URL i loaded the first time. Is there any way to fix that?
Here is the Activity:
public class PhonegapCallsActivity extends DroidGap {
private static Boolean backButton;
private static String url;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
if (extras == null) {
Log.d("false","ERROR");
//load index.html when i enter first time
super.loadUrl("file:///android_asset/www/index.html");
return;
}
else{
backButton = extras.getBoolean("backButton");
//load #two when i come back
Log.d("true","ERROR");
super.loadUrl("file:///android_asset/www/index.html#two");
}
}
Note that logcat is tracing true and false correctly, so my variables are set properly.
I always get the index.html loaded, never index.html#two. Is it stored somewhere?
You are doing it right but you are running into an Android bug. Go star:
https://code.google.com/p/android/issues/detail?id=17535
https://code.google.com/p/android/issues/detail?id=17327
In the mean time the best way to work around this issue is to store a flag in localStorage to check if you should be loading page one or page two in the JavaScript.

How to make a web app for android?

I’ve been making android apps for like 4-5 days now. So i’m wondering if you know how I can make a web app? I have been looking through many tutorials, but none shows directly how I can make an app that displays the content from a website, and that I can decide what I want and don’t want to display. So I really just want to customize a website into an app and make my own layout. I know how the WebView and WebContent works and all that stuff, but I don’t know how I can do what I described here.
So what do I need to learn and know to make an app like that?
You can do it by fill your xml layout with EdidText for the url and Buttons for Go, back, forward and so on, finally you need webview in this xml layout.
for the java code you can check the below sample.
public class SimpleBrowser extends Activity implements OnClickListener {
WebView myBrowser;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simplebrowser);
//here the code for initialize and set yourwebView Settings.
myBrowser= (WebView) findViewById(R.id.wvBrowser);
//the below line to enable javascript if you want that
myBrowser.getSettings().setJavaScriptEnabled(true);
//here another settings could be enabled for you your webview
myBrowser.getSettings().setLoadWithOverviewMode(true);
myBrowser.getSettings().setUseWideViewPort(true);
try {
//here the default web page
ourBrow.loadUrl("http://www.google.com");
}catch (Exception e){
e.printStackTrace();
}
}
}
and for sure you need to implements your buttons using onClicklistener to be suitable for your idea.
https://www.youtube.com/watch?v=lkadcYQ6SuY&index=89&list=PL2F07DBCDCC01493A
https://www.youtube.com/watch?v=PQ94MmEg0Qw&index=90&list=PL2F07DBCDCC01493A

Categories

Resources