Posts

Showing posts from November, 2013

solve one issue because of thread safe httpclient

I was using HttpClient to handle the http request and response. Previously I always debug on latest phones which are upper 4.0 everything works fine. One day I tried on my older phone Moto Defy running 2.3.7 from Cyanogenmod . There was one issue when I tried to post an image . I got the log : Invalid use of SingleClientConnManager: connection still allocated. or Caused by: java.lang.IllegalStateException: No wrapped connection. or Caused by: java.lang.IllegalStateException: Adapter is detached. Searched in stackoverflow normally it is because of accessing single instance of HttpClient in different thread or did not close InputStream of httpresponse.  Mine issue is the first one.  So I learnt one solution to get a thread safe httpclient. public static DefaultHttpClient getThreadSafeClient () { DefaultHttpClient client = new DefaultHttpClient (); ClientConnectionManager mgr = client . getConnectionManager (); HttpParams params = cli

Android Trick - AutoCompleteTextView & MultiAutoCompleteTextView & Spannable & EditText

Story came from I tried implement an EditText View which supports "Mention feature" like Facebook and Twitter. After user type in "@" symbol there is a dropdown list come out and let user select some item to replace that word started with "@". The first I try to use EditText and popup window to customize this component. Which I need to listen EditText text change and using popup window to show the dropdown list with suggestions. But when I tried to handle the focus between EditText and PopupWindow I gave up this way . Could not find better solution for that means when EditText get focus all the time my dropdown list can not be clicked . Because popup window needs focusable to make views inside can be clicked. But if I give popup window focus user can not type in anymore. Then I realized how stupid I worked. There supposed to be a solution from Android . Coz Contacts app support autocompletion. Then I found AutoCompleteTextView . Followed docume