Catch Exception in JavaScript

by kevin » Wed, 08 Apr 2009 19:47:38 GMT

Sponsored Links
 My application uses WebView to load javascript which calls into Java
class (through webview javascript iterface). Can the JavaScript catch
exceptions thrown from Java? This is very important for the
application, any help is appreciated.


Catch Exception in JavaScript

by kevin » Thu, 09 Apr 2009 11:35:48 GMT

 Anyone can help on this? I tried to catch exception in javascript but
doesn't work, is it because webview not support javascript exception



Sponsored Links

Catch Exception in JavaScript

by Mattaku Betsujin » Thu, 09 Apr 2009 11:43:57 GMT

 I think the answer is no. If java JavaScript calls Java, and the Java method
throws an uncaught exception, it kills the app process.

Your best bet is to put a try-catch block around every Java method that can
be called by Javascript.

Just curious. What kind of exception are you expecting? I have written quite
a bit of JavaScript -> java calls in my app and this has never been an issue
for me.
2009/4/8 kevin <>


Catch Exception in JavaScript

by kevin » Tue, 14 Apr 2009 09:56:08 GMT

 My javascript calls Java to do IO operation, I was trying to catch
IOException inside javascript.



Other Threads

1. How to verify the Activity on the foreGround

Hi Android Experts,

I am very new to White box testing. And its really good and
Challenging to work on Unit Testing.

I need to know how to verify when an activity is launched .

I tried the following method :
public class MainActivityTest extends ActivityInstrumentationTestCase2

        private MainActivity mMainActivity;
        private Activity mActivity;
        private Instrumentation mInstrumentation;
        private Context mContext;
        private KeyguardManager mKeyGuardManager;
        private Lock mLock;

        public MainActivityTest()
                super("", MainActivity.class);
                // TODO Auto-generated constructor stub

        public void setUp()throws Exception
                System.out.println("In SetUp Method");

                //Disables the Touch

                //Makes sure that Key Lock is disabled
                /* mKeyGuardManager = (KeyguardManager)
                 mLock = (Lock)
                ((KeyguardLock) mLock).disableKeyguard();*/

                //Initializes Instrumentation for test cases
                mInstrumentation = getInstrumentation();
                mActivity =getActivity();
                System.out.println("mActivity in setUp"+mActivity);

        public void testPreconditions()


        //To test whether the targeted Activity is getting launched
        public void testLaunchActivity()throws Exception

                System.out.println("mActivity in setUp"+mActivity);


When executed the above test application, the activity is getting
launched successfully. But the Test case fails becuse
of the following exception from the assert method.

04-14 16:04:05.183: INFO/TestRunner(8585):
expected:<> but

How do i make it work.??
Any kind of solution would be highly appretiated...



2. don't duplicate data in database

I have an application that have a tabactivity. When I do click in any
tab get some Internet information and shows it in a ListView and then
record the information in a database.
Well, I would like that when I exit of the application removes the
information of the database, by these way I obtain that don't have
duplicate information.
Many thanks and sorry for my english!


3. How can I get current activity from context?

4. Static class variables reset to null after task kill/restart

5. when activity loads first time onscroll method is called?

6. Android WIFI driver porting

7. Why bionic stdio can not support 64bit file?