Select chapter



basics (6.papers)
activities (5.papers)
services (2.papers)
threads (2.papers)
receivers (1.papers)
advanced android (2.papers)
SQLite database (1.papers)
adapters (1.papers)
adb and ddms (1.papers)
widgets (1.papers)
fragments (1.papers)
UI (1.papers)
Hide

Sponsored Links


  

android interview questions and answers

1
Which method need to be called to shut down an activity, itself?
  1. onDestroy()
  2. finish()
  3. finishActivity()
  4. None are correct.
Show Answer
Share Facebook gmail Twitter
2
Which of the following are true about enabling/disabling menu items from an Activity class?
  1. The menu items in an Android application cannot be disabled.
  2. onCreateOptionsMenu can be used to enable/disable some menu items in an Android application.
  3. onPrepareOptionsMenu can be used to enable/disable some menu items in an Android application.
  4. onShowOptionsMenu can be used to enable/disable some menu items in an Android application.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
4
What is the difference between Activity context and Application context ?
  1. The activity instance is tied to the lifecycle of an application while the application instance  is tied to the lifecycle of an application.
  2. The activity instance is tied to the lifecycle of an activity while the application instance  is tied to the lifecycle of an application.
  3. No difference.
  4. None are correct.
Show Answer
Share Facebook gmail Twitter
5
What is the difference between view and viewgroup in android?
  1. View is a basic building block of UI (User Interface) in android. A view is a small rectangular box which responds to user inputs. Eg: EditText, Button, CheckBox, etc..
  2. ViewGroup is a invisible container of other views (child views) and other viewgroups. Eg: LinearLayout is a viewgroup which can contain other views in it.
  3. ViewGroup is a special kind of view which is extended from View as its base class. ViewGroup is the base class for layouts.
  4. all are true
Show Answer
Share Facebook gmail Twitter
6
What is the difference between margin and padding in android?
  1. Margin specifies the extra space left on all four sides of a view. Margin space is generally outside the view's bounds. To leave space on left side use android:margin_left, to leave space on other sides use android:layout_marginRight, android:layout_marginTop, android:layout_marginBottom etc..
  2. Padding is used to offset the content of a view by specifying pixels. For example a left padding of 2 wil push views content 2 pixels right side of the left edge. Use android:padding
    android:paddingBottom
    android:paddingLeft
    android:paddingRight
    android:paddingTop to set padding on various sides of the content of that view.
  3. both options are true
  4. Margin is the offset for the content of the view, and padding is the space outside the view's bounds. Other wise both option 1 and option 2 are correct.
Show Answer
Share Facebook gmail Twitter
7
Suppose MyView is a class derived from View and mView is a variable of type MyView. Which of the following should be used to display mView when the Android application is started?
  1. Call setContentView(mView) in the onStart() of the main application class.
  2. Call setCurrentView(mView) in the onCreate() of the main application class.
  3. Call setContentView(mView) in the onCreate() of the main application class.
  4. Call setCurrentView(mView) in the startApp() of the main application class.
Show Answer
Share Facebook gmail Twitter
8
Which of the following are appropriate for saving the state of an android applications?
  1. Activity.onFreeze()
  2. Activity.onStop()
  3. Activity.onPause()
  4. Activity.onDestroy()
Show Answer
Share Facebook gmail Twitter
9
How does android achieve seamlessness. What is the meaning of seamlessness?
  1. by handling onSaveInstanceState. Seamlessness means uninterrupted flow of application.
  2. by handling configuration changes, seamless meaning is same as option 1
  3. by handling low memory scenarios, seamlessness meaning is same as 1.
  4. all options are true
Show Answer
Share Facebook gmail Twitter
10
What does the flag FLAG_ACTIVITY_NEW_TASK do here?

Intent in = new Intent();
in.setAction("com.android.myproject.MYACTION");
in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(in);
  1. It will start a new activity with matching intent filter, in a new task always.
  2. It will start a new activity with matching intent filter, in a new task only if that corresponding task is not in memory now.
  3. It will start a new activity with matching intent filter, in old task always. here old task means task in which the current activity is running which has started new activity.
  4. This will start a new activity in a new task, where only this activity will be there in that task and no other components. if at all new components are launched from this new activity, they will be launched in a different task.
Show Answer
Share Facebook gmail Twitter
11
What does the flag FLAG_ACTIVITY_SINGLE_INSTANCE do here?

Intent in = new Intent();
in.setAction("com.android.myproject.MYACTION");
in.setFlags(Intent.FLAG_ACTIVITY_SINGLE_INSTANCE);
startActivity(in);
  1. It will start a new activity with matching intent filter, in a new task always.
  2. It will start a new activity with matching intent filter, in a new task only if that corresponding task is not in memory now.
  3. It will start a new activity with matching intent filter, in old task always. here old task means task in which the current activity is running which has started new activity.
  4. This will start a new activity in a new task, where only this activity will be there in that task and no other components. if at all new components are launched from this new activity, they will be launched in a different task.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
13
What is android activity creator tool?
  1. tool used to create an activity
  2. command line tool or batch file to create android project.
  3. it is used to compile the android java files into .class file
  4. none
Show Answer
Share Facebook gmail Twitter
14
What is activity manager in android?
  1. Activity manager is used to monitor and manage activity stack.
  2. we can use activity manager to retrieve information about tasks that user has visited recently, information about currently running processes, information about perticulare task that is currently running, etc..
  3. both options are true
  4. none
Show Answer
Share Facebook gmail Twitter
15
What is activity animation in android?
  1. playing animtion in an activity is called as activity animation.
  2. Applying transition and scaling animations while moving from one activity to other activity is called as activity animation, to make it appear as if they are sliding and zooming in and out.
  3. both are true
  4. none
Show Answer
Share Facebook gmail Twitter
16
What is activity transition animation in android? How to do activity transition animation?
  1. A Transition is a mechanism to automatically animate changes that occur when a new scene is entered.
  2. When a transition is applied while moving from one activity to other activity, then new activity will appear as if it is sliding from right to left. While moving in the new activity, you can apply some animation to old activity to apear as if it is fading out by using alpha.
  3. A sample code:
    
    Go to resources->anim folder-> create opening_trans.xml
    
    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate android:fromXDelta="100%"
                   android:toXDelta="0%"
                   android:duration="@android:integer/config_mediumAnimTime" />
    </set>
    
    Go to resources->anim folder-> create closing_scale.xml
    
    <set xmlns:android="http://schemas.android.com/apk/res/android">
    
        <scale android:fromXScale="80%p"
              android:toXScale="100%p"
              android:fromYScale="80%p"
              android:toYScale="100%p"
              android:pivotX="50%p"
              android:pivotY="50%p"                              android:duration="@android:integer/config_mediumAnimTime" />
    
        <alpha android:fromAlpha="0.5"
              android:toAlpha="1.0"
              android:duration="@android:integer/config_mediumAnimTime"/>
    </set>
    
    Go to your activity
    @Override
      protected void onCreate(Bundle savedInstanceState)
      {
        super.onCreate(savedInstanceState);
        //apply opening animation
        overridePendingTransition(R.anim.opening_trans,R.anim.closing_scale);
      }
  4. all are true
Show Answer
Share Facebook gmail Twitter
17
In android how to hide keyboard?
  1. Programatically we can close virtual keyboard with below code.
    
    InputMethodManager inputManager = (InputMethodManager)            
    this.getSystemService(Context.INPUT_METHOD_SERVICE); 
    inputManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 
      InputMethodManager.HIDE_NOT_ALWAYS);
  2. Programatically we can close virtual keyboard with below code.
    
    getWindow().setSoftInputMode(      WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  3. If it is not through programming, a mobiler user can hide the virtual keyboard by swiping keyboard from top to bottom very quickly. Many of the virtual keyboards support this operation to hide.
  4. all are true
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
19
What are the different screen sizes available or supported in android?
  1. android supports 4 variants of screen sizes: small, normal, large, and extra large
  2. xlarge screens are at least 960dp x 720dp resolution
    large screens are at least 640dp x 480dp resolution
    normal screens are at least 470dp x 320dp resolution
    small screens are at least 426dp x 320dp resolution
  3. both options are true
  4. none
Show Answer
Share Facebook gmail Twitter
20
In android how to get difference between two dates?
  1. Assume that two dates are d1, and d2.
    
    long dif_dates = d1.getTime() - d2.getTime();
    long secs = dif_dates / 1000;
    long mins = seconds / 60;
    long hours = minutes / 60;
    long days = hours / 24;
  2. assume that you have two dates secondDate and firstDate.
    
    long dateDif = secondDate.getTime() - firstDate.getTime();
    
    long difference = TimeUnit.MILLISECONDS.toSeconds(dateDif);
    
  3. both are true. But second option gives difference in terms of seconds, where as first one in terms of days, hours.
  4. none
Show Answer
Share Facebook gmail Twitter
Read more papers :