Javascript, WebView, and arrow keys.

by Ken Perry » Fri, 10 Sep 2010 00:22:12 GMT

Sponsored Links
 The following question has to do with Froyo 2.2 sdk 8 running on an


 I am injecting Javascript  into a web page and in the WebView activity I
get 19, 20, 21, and 22 for key codes for arrow keys.  At the Javascript
level all four arrow key values in a keydown handler come in as zero.  The
following is the java script code I am using to set the handler and to get
the keyValue.


window.addEventListener('keydown', keyDownHandler, true); 


function keyDownHandler(evt){

var keyCode=evt.keyCode;





I will note that keys like enter come in correct for example I get 13 for
enter.  I also will note that if I press shift and then an arrow key I get
16 for all 4 arrow keys instead of 0.  myLog function takes a String but the
following works 


If (keyCode==0){

myLog("arrow key");



So the value is coming in as zero is there some way I can fix this.  If
someone has time I have a pretty simple example of this problem I could
probably zip up as an eclipse project.







Other Threads

1. XML stream corruption

I am writing a client on Android for a "corporate twitter" system. I
have written the http-request/response handling in Java on windows
first, and migrated the source to my Android project once I saw it
work. No changes seemed to have to be done to the source, it compiled

However, since our users are swedish we have a heavy use of umlauts in
the "twitter" messages, and the messages received in the xml from the
server becomes corrupted at the first umlaut. At first I thought it
was something with the TextView widget, but it turned out I can hard
code a swedish sentence and it is printed correctly in the TextView.
None of this is problem in Java SE on windows, but the strings seems
to be corrupted when read from the httpClient in Android.

I collect the xml text this way:

public myResponse handleResponse( HttpResponse response ) throws
ClientProtocolException, IOException
                HttpEntity entity = response.getEntity();
                BufferedReader reader = null;
                StringBuffer buffer = new StringBuffer();
                String inputLine = null;
                YammerResponse messageResponse = null;

                if (entity != null)
                        reader = new BufferedReader( new InputStreamReader
( entity.getContent(), "UTF-8" ));

                    while( (inputLine = reader.readLine()) != null )
                        buffer.append( inputLine );

                    messageResponse = new ResponseParser().parseString
( buffer.toString());

                System.out.println( "Response parsed! ");

                return messageResponse;

I would appreciate some help here!



2. Launching App from a browser


I am desperately trying to launch android app from a browser via a
link in a page.
I tried all the options using Intent Filters but none of them seemed
to work.

Please point to an example



3. Problems with Accelerometer - random values

4. Tasks Running in Android

5. retreive data from servlet

6. Learning Android Development

7. question about intents