Friday, 25 April 2014

Get the text in the search box of a action bar

It was a little difficult for me to get the text which is entered in the action bar to a string. Please check the below code .


public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.main, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search)
            .getActionView();
    if (null != searchView) {
        searchView.setSearchableInfo(searchManager
                .getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(false);
    }

    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            // this is your adapter that will be filtered
            return true;
        }

        public boolean onQueryTextSubmit(String query) {
            //Here u can get the value "query" which is entered in the search box.

        }
    };
    searchView.setOnQueryTextListener(queryTextListener);

    return super.onCreateOptionsMenu(menu);
}

Saturday, 19 April 2014

HTTP client to help test web services easily and efficiently



While i was dealing with Apps which is connect to serve the main issue i faced was checking the response. What i used at staring was debugging the app each time. In the case of json parsing I waste a lot of time only for checking the responses.
Then i got a solution Postman - REST Client.

It is very simple. You can POST or GET data to the server using postman. 

InstalPostman


Wednesday, 16 April 2014

A Better Emulator For Android.



The in built emulator of android is very slow. It will take a lot of time for debugging in that emulator. You can use a better emulator Genymotion . It is very simple , just log in and download the gennymotion.

Please check the User Guide for more details.

Android Messaging.

If you search for live messaging in android you will get a lot of 3rd party links. That are complex ,just follow the below link, it is very simple. You can use ip of localhost as 10.0.2.2.
One more thing ,make sure that messages are not getting blocked by your firewall, it happened to me when I was testing my app on our corporate network

Android Messaging.

If you have any problem with the working please check the  demo video.

You can use Android ListView with Speech Bubble to make the chat good looking.