Listen to Virtual Keyboard events when within an EditText

by roma » Wed, 17 Mar 2010 01:09:43 GMT


Sponsored Links
 I have confirmed it by making various attempts with this listener, it
will not work for alphabetic inputs from the virtual keyboard on
device. You can use the TextWatcher instead which can serve the
purpose if you dont want to specifically catch the onKeyUp() and
onKeyDown() events. It works pretty fine.

You can try adding the textWatcher using the
addTextChangeListener(textWatcher) on a textView or its subclass
views.

Hope this helps!

--



Other Threads

1. Windows 7 & Android development environment question

Hi all,

Can you please advise if development tools Eclipse, Android sdk, usb
driver etc. are working properly under Windows 7 32 and 64 bit?

Thanks,
Evgeny

-- 

2. The problem of using GData APIs to upload video to YouTube.

Hi all,

        Recently, I want to develop a simple application to upload
videos to YouTube. But after reading the

        tutorial of YouTube Data API.
(http://code.google.com/intl/zh-TW/apis/youtube/2.0/
developers_guide_protocol_direct_uploading.html)

        I don't know how to fix the problem I encounter now.

        The following is my code and after executing it, the HTTP
response code is 400 (Bad Request) and

        the error message is "Incomplete Multipart Body".

        Please give me some suggestions and directions.

        Thank you very much.


[MyCode]
public void upload(String token, String clientID, String developerKey,
File file)
        {

          String youtubeUrl = "http://uploads.gdata.youtube.com/feeds/api/
users/default/uploads";
          URL url = null;

                try
                {
                        url = new URL(youtubeUrl);

                        conn = (HttpURLConnection) url.openConnection();

                        conn.setDoInput(true);
                        conn.setDoOutput(true);
                        conn.setRequestMethod("POST");
                        conn.setUseCaches(false);

                        conn.setRequestProperty("Host", 
"uploads.gdata.youtube.com");
                conn.setRequestProperty("Authorization", "GoogleLogin auth=\"" +
token + "\"");
                conn.setRequestProperty("GData-Version", "2");
                conn.setRequestProperty("X-GData-Client", clientID);
                conn.setRequestProperty("X-GData-Key", "key=" + developerKey);
                conn.setRequestProperty("Slug", file.getName());
                conn.setRequestProperty("Content-Type", "multipart/related;
boundary=\"" + boundary + "\"");
                conn.setRequestProperty("Content-Length", getLength());
                conn.setRequestProperty("Connection", "close");


                DataOutputStream writer = new 
DataOutputStream(conn.getOutputStream
());

                        writer.write(("\r\n--" + boundary + "\r\n").getBytes());
                        writer.write("Content-Type: application/atom+xml; 
charset=UTF-8\r\n
\r\n".getBytes());
                        writer.write(getXml().getBytes("UTF-8"));
                        writer.write(("--" + boundary + "\r\n").getBytes());
                        writer.write("Content-Type: video/mp4\r\n".getBytes());
                        writer.write("Content-Transfer-Encoding: 
binary\r\n\r\n".getBytes
());
                        FileInputStream reader = new FileInputStream(file);

                        byte[] array;

                        int bufferSize = Math.min(reader.available(), 2048);
                        array = new byte[bufferSize];

                        int read = 0;

                        read = reader.read(array, 0, bufferSize);

                        while ( read > 0)
                        {
                                writer.write(array, 0, bufferSize);
                                bufferSize = Math.min(reader.available(), 2048);
                                read = reader.read(array, 0, bufferSize);
                        }

                        writer.write(("--" + boundary + "--").getBytes());
                        writer.flush();
                        writer.close();
                        reader.close();
                        }
                        catch(Exception ex)
                        {
                           Log.e("Error", ex.toString());
      }
}

private String getXml()
        {
                String xml = "<atom:entry 
xmlns:atom=\"http://www.w3.org/2005/Atom\">
\r\n" +
                                        "<media:group 
xmlns:media=\"http://search.yahoo.com/mrss/\">\r\n"
+
                                        "<media:category 
scheme=\"http://gdata.youtube.com/schemas/2007/
categories.cat\">\r\n" +
                                        "People\r\n" +
                                        "</media:category>\r\n" +
                                        "<media:category 
scheme=\"http://gdata.youtube.com/schemas/2007/
developertags.cat\">alfa\r\n" +
                                        "</media:category>\r\n" +
                                        "<media:category 
scheme=\"http://gdata.youtube.com/schemas/2007/
developertags.cat\"> 6ipt2uPhg9e46kl9 \r\n" +
                                        "</media:category>\r\n" +
                                        "<media:category 
scheme=\"http://gdata.youtube.com/schemas/2007/
developertags.cat\">cF5GktQvk6f0kt8s\r\n" +
                                        "</media:category>\r\n" +
                                        "<media:description>Answers to Question 
cF5GktQvk6f0kt8s\r\n" +
                                        "</media:description>\r\n" +
                                        "<media:keywords> alfa, 
answer</media:keywords> <media:title> \r
\n" +
                                        "Answers to Question 
cF5GktQvk6f0kt8s\r\n" +
                                        "</media:title>\r\n" +
                                        "</media:group>\r\n" +
                                        "</atom:entry>\r\n";

                return xml;
        }

private String getOutput()
{
                StringBuilder sb = new StringBuilder();

                sb.append("\r\n--" + boundary + "\r\n");
                sb.append("Content-Type: application/atom+xml; 
charset=UTF-8\r\n\r
\n");
                try {
                        sb.append(new String(getXml().getBytes("UTF-8"), 
"UTF-8"));
                } catch (UnsupportedEncodingException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                sb.append("--" + boundary + "\r\n");
                sb.append("Content-Type: video/mp4\r\n");
                sb.append("Content-Transfer-Encoding: binary\r\n\r\n");

                return sb.toString();
}

private String getLength()
{
                long length = getOutput().getBytes().length + ("--" + boundary +
"--").getBytes().length + file.length();
                return String.valueOf(length);
}
[/MyCode]

-- 

3. customer changes phone, wants app again but market doesn't show app as purchased

4. ps3 remote control

5. Permission denied for installing apk in phone

6. android : error on build-impl.xml:338:

7. Android and SyncML