1

I'm trying to develop this "cloud-like" Android application, but I can't get JavaScript to execute inside the application. Here is the java part of my activity...

This all works fine, but on http://www.webprogramming360.com/SpanishQuizMe/lesson.php it calls for a JavaScript page (it's live so you can see it now), but with an onClick JavaScirpt event a function on the called JavaScript page located here http://www.webprogramming360.com/SpanishQuizMe/lesson.js won't execute.

How can I get that function to execute? Is javascript even working? And will the Android Market Place accept an app like this (one that is in the cloud/the main part of the code is live online)

    package com.something.something;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class QuizSplashActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         //setContentView(R.layout.splash);

         // Let's display the progress in the activity title bar, like the
         // browser app does.
         getWindow().requestFeature(Window.FEATURE_PROGRESS);

         WebView webview = new WebView(this);
         setContentView(webview);

         webview.getSettings().setJavaScriptEnabled(true);

         final Activity activity = this;
         webview.setWebChromeClient(new WebChromeClient() {
         public void onProgressChanged(WebView view, int progress) {
              // Activities and WebViews measure progress with different scales.
              // The progress meter will automatically disappear when we reach 100%
              activity.setProgress(progress * 1000);
         }
       });

webview.setWebViewClient(new WebViewClient() {

public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
         //Users will be notified in case there's an error (i.e. no internet connection)
         Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
}
});
      //This will load the webpage that we want to see
       webview.loadUrl("http://www.webprogramming360.com/SpanishQuizMe/");

    }
}
1
  • Have you fixed this issue? I tried this code out on a Gingerbread phone and it seemed to work fine. Nov 25, 2011 at 17:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.