Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By pbrockway2

Thread: Help ..~

  1. #1
    SuperPig is offline Member
    Join Date
    Jul 2011
    Rep Power

    Default Help ..~

    what is the meaning of class stub? ( i found this term in the android developers )
    Also, can anyone explain to me about Context? The definition given by Android developers is "A Context is a handle to the system". What handle is that?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    New Zealand
    Rep Power


    A stub is a piece of code that keeps the compiler happy by declaring all the right things but is missing the actual code you would write to implement actual behaviour.

    Eg the following is a method stub:

    Java Code:
    public int getCount() {
        // TODO: calculate the count and return it here
        return 0;
    The point is that you have to replace the comment with something meaningful. When you create an android project in Eclipse (or other IDE) a number of classes are created: again, they are class stubs and you have to complete them by filling in the actual code you want. (In particular a subclass of Activity might be created with the name you specify when you create the project.)

    handle is another general purpose word that means a "way of getting at something". In Java a more common word might be interface.

    As far as Android is concerned Context is an abstract class that provides lots of methods - like getApplicationInfo(), getResources(), and especially startService() and startActivity() - which get information from the Android system or tell it to do something. For instance when you call startActivity() this tells the Android system the sort of thing you want to happen and the system will respond by launching some program or other that will carry out that intent.

    Such an abstract class that provides methods for working with the system as a whole is described as "providing a handle" to the system.
    sunde887 likes this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts