How to capture Soft keyboard key events.

by Gulfam » Thu, 29 Oct 2009 00:42:14 GMT


Sponsored Links
 Hi all group members,

I am facing a problem any one can help me regarding this.

I have an  EditText and a list of contacts. I want to search a
contacts on maching with characters entered in EditText field. In my
activity I have implemented  "OnKeyListener" .

and in onCreat (){
  searchField = (EditText)findViewById(R.id.search_field);
  searchField.setOnKeyListener(this);
}
 and i have also implemented the method like this

public boolean onKey(View v, int keyCode, KeyEvent event) {

//Here i am getting text from my search field and comparing with
contacts and updating contacts list
}

When i pressed keys like (abc ---> xyz or 0 -->9 or any key) from my
computer key board or
keyboard which is displaying on right side of the emulator my code is
working fine. Currently I am using HTC Magic Emulator and Device also.

*******Its workin fine for me******
But now move to issue-->>>

when i touch EditText field  a software keyboard launched and when i
pressed any key from my screen keyboard
its not giving me the events in onKey() method in other words its not
calling onKey(){} method. but this method is called on specific keys
like (0 to 9 and Delete key).

I have also implement "keyListener" interface and its 4 to 5 methods
like keyUp(), keyDown(),etc  but when i implement "keyListener"
softkeyboard is not launching on touching my EditText field.

Any useful solution would be highly appriciated.
Thanks in advance.
Gulfam Hassan

--~--~---------~--~----~------------~-------~--~----~



How to capture Soft keyboard key events.

by Gulfam » Thu, 29 Oct 2009 23:10:09 GMT


 Is there any solution I am still waiting for your Response

Gulfam Hassa



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


How to capture Soft keyboard key events.

by Banny » Fri, 30 Oct 2009 11:22:17 GMT


 I find the same problem of it.
Finally, I found EditText.addTextChangedListener(new TextWatcher(){})
will let get the event.
Good luck.





--~--~---------~--~----~------------~-------~--~----~



How to capture Soft keyboard key events.

by Gulfam » Fri, 30 Oct 2009 15:18:32 GMT


 Hi Banny,

Thanks alot. I have implemented the code same as you its working very
well for me. It was very big issue for my app but now resolved :)
Thanks again.

Regads,
Gulfam Hassan





--~--~---------~--~----~------------~-------~--~----~



How to capture Soft keyboard key events.

by Nandy » Fri, 30 Oct 2009 18:57:21 GMT


 Hi Banny, Hassan,

Even i faced the same problem and added on text change listener
through text watcher. But in this case I am not able to catch the
events of keys like caps, shift, changing from abc to 123.
Any idea on this how to solve?

Thanks and Regards,
Nandy






--~--~---------~--~----~------------~-------~--~----~



How to capture Soft keyboard key events.

by Dianne Hackborn » Fri, 30 Oct 2009 20:46:00 GMT


 here are no events for those things.  They are just internal state changes
in the IME. Some IMEs may not even have such changes -- for example a
handwriting one may allow you to write letters and numbers in the same area.

On Fri, Oct 30, 2009 at 3:56 AM, Nandy <satirthana...@gmail.com> wrote:



--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Looking for definitive location finding logic



AFAIK it is a viable option, but:

-- Use unique LocationListener objects not one single one

-- Be sure to call removeLocationUpdates() for all of those
LocationListener objects

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Consulting: http://commonsware.com/consulting

-- 

2. Looking for definitive location finding logic

I am looking for a tutorial that explains the logic for fast, robust
location finding.

Basically I am sick of Google Maps finding my location so incredibly
fast and accurately while my own application struggles to get a
location.

I would be fine with pseudo code responses and I will explain what I
am doing so maybe I can be shown what I am doing wrong.

1. Get the locationManager object.
2. Do a 'get best provider' call.
3. Get a list of all available providers.
4. lm.requestLocationUpdates(bestProvider, 0, 0, this);   // hit the
location provider as much as I can to get my first signal
5. Send a delayed message.  If a location cannot be found in 10
seconds, switch to a different provider and try again with
lm.requestLocationUpdates(nextProvider, 0, 0, this);
6. Repeat step 5 until I have a location.
7. Once a location is found determine if it is the most accurate
provider.  If it is not try again with the most accurate provider on
an 8 second delay.  If it is the most accurate provider then set
lm.requestLocationUpdates(currentProvider, 30000, 0, this); to
conserve battery
8. Make sure to lm.removeUpdates(this); before changing the
requestLocationUpdates

Now it occurs to me that it may be possible to iterate through my list
of providers and do requestLocationUpdates for all providers at once.
Is this a viable option or can you only listen to one provider at a
time?  I have seen that location from onLocationChanged has
getProvider() to let you know who provided the location information so
that I can know which provider is actually finding a signal and turn
off the others.

-- 

3. startActivityForResult and setResult problems

4. Launch Google Maps app

5. Touchscreen support for 7 Inch LCD panel

6. finish parent activity from child

7. Harga milestones di malaysia :)