Saturday, February 9, 2013

Android: Find LogCat window



Can't find LogCat window to view Log messages.

Here are the steps to find it.































On your Eclipse.. In the bottom Panel you should see LogCat window now.





























Android: Printing console messages



First things first.. While coding everyone wants to log something or other in console for various purposes. iPhone has NSLog and Android has Log.d , Log.v .. In debug mode of app we can just use Log.d  and view the logs in LogCat Window. Can't find LogCat Window ?


This sample take values from an array and prints it in Log.

String itemValue=listArray[position]; Log.d("item value clicked is", itemValue);



How to print integer in Log.d ? Lets say you want to print length of listArray array which is an int.


Log.d("listArray length", String.format("array length = %d", listArray.length));

Android: Invoke a method after some delay



If you have a method which you want to call after some delay



        //Create a delay handler
        Handler delayHandler= new Handler();
        Runnable r=new Runnable()
        {
@Override
public void run() {

// Call this method after 1000 milliseconds
showCountryListViewIntent();
}
        
        };
        delayHandler.postDelayed(r, 1000);



    ///This method will be called after say 1000 milliseconds.
    //This will call the another Activity
    public void showCountryListViewIntent()
    {
    Intent countryListIntent=new Intent(this,CountryListActivity.class);
    startActivity(countryListIntent);
    }


You can find the sample code DOWNLOADABLE HERE.





Android: Navigate from one screen to another





From your current activity to want to switch to a new activity. You can do so as following



Intent newIntent=new Intent(this,SecondActivity.class);
startActivity(newIntent);



You can find the sample code if it is still not clear. LINK



Friday, February 8, 2013

Spotlight on Mac




Spotlight you can find anything on your Macintosh really quick.
Its a search icon on the top right on your macintosh screen.














ADB Error: The connection to adb is down




If you are getting following error while trying to run the android code on your AVD


The connection to adb is down, and a severe error has occured.
You must restart adb and Eclipse.
Please ensure that adb is correctly located at 'PATH' and can be executed.



Following tip may be help you :
Close your eclipse.Open the Activity Monitor and quit the process named abd process from the list.
I have highlighted the one you want to remove. Restart the eclipse and run your app now.




































Where to find the Activity Monitor ? Try Spotlight on your mac. Where is Spotlight ?




Outline Window in Eclipse ADT




Trying to find outline window ?

No worries if you closed it by mistake and you want to bring it back. Here is the path.


































Here is what Outline Window looks like, in right panel of Eclipse. You will be able to view all the child views in your xml file in Outline window.