#getbasecontext
Explore tagged Tumblr posts
Link
original source : http://stackoverflow.com/questions/10641144/difference-between-getcontext-getapplicationcontext-getbasecontext-and
View.getContext(): Returns the context the view is currently running in. Usually the currently active Activity.
Activity.getApplicationContext(): Returns the context for the entire application (the process all the Activities are running inside of). Use this instead of the current Activity context if you need a context tied to the lifecycle of the entire application, not just the current Activity.
ContextWrapper.getBaseContext(): If you need access to a Context from within another context, you use a ContextWrapper. The Context referred to from inside that ContextWrapper is accessed via getBaseContext().
0 notes
Link

Top 20 Android Interview questions you must prepare for Android
Android Application developers are in great demand in this modern era, and it is also one of the highest-paying career. As a result, many tech-savvy individuals are attempting to get into this field.
Many multinational corporations (MNCs) and small businesses offer tough interview questions.
This article contains a list of Android interview questions and answers that will be useful to both freshers and experienced professionals who seeking for Android career.

Android activity life cycle
1. Latest version of Android
Android 11- September 8, 2020 – API Level – 30
2. What are the different stages of the Activity life cycle in Android?
onCreate
onStart
onResume
onPause
onStop
onRestart
onDestroy
3. What are the types of intents in Android?
Two types of intent in Android .
Implicit Intent Implicit intent does not specify any components. It is used to invoke an actions.
Explicit Intent Explicit intents used to start an activity, send data between two activities.
4. What is the use of AndroidManifest.xml file in Android application?
AndroidManifest.xml file includes all components in an Android application such as the activities, services, content providers, broadcast receivers.
5. What is a Toast ?
Toast is a small piece of message displayed on the screen, similar to tooltips and popup notifications. We can define a time such as LENGTH_SHORT and LENGTH_LONG to specifying the duration of toast message to be displayed on the screen.
6. Why we need to use fragments is Android?
Fragments help to create UI rich design for the app, pass data between different screens, and we can split a single screen into multiple subdivisions to improve our app performance.
7. Why WebView?
WebView in Android used to display web page in the application. This can be done by using the loadUrl() and loadData() methods. The WebView can only display the online content to the particular Android activity.
8. What are the components in an Android project explorer?
The Android Studio project explorer contains all files needed to make up the project. There are two sub folders in the project explorer.
app – The app folder again have three sub folders such as manifest, java, res.
Gradle Scripts – The dependency file such as the java libraries, other plugins.
9. What are activities?
Activities in Android application are the screens that displayed on a device. An app can contain more than one activity, meaning one or more screens.
10. What is mean by screen orientation in Android?
Screen orientation is a property of activity to define the change from one state to another. There are various type of screen orientations they are portrait, landscape, sensor, unspecified etc.
11. Difference between activities and services?
Activities in Android application are the screens that displayed on a device. A Service in Android used to perform long-running operations in the background.
12. Use of bundle in Android?
Bundle in Android is used to pass data between Activities.
13. Different types of dialog boxes in Android?
There are four type of Android dialogs
Alert Dialog.
DatePicker Dialog.
TimePicker Dialog.
Custom Dialog.
14. Difference between compileSdkVersion and targetSdkVersion?
The compileSdkVersion that defines which Android SDK version will be used by Gradle to compile the application. The targetSdkVersion property specifies the Android version for which the app was built and tested.
15. apk stands for _____?
Android Application Package
16. What is an Adapter in Android?
The adapter is to act as a bridge between the adapter and its related data.
17. What is mean by Views in Android?
The UI elements in Android are called Views. Eg: EditText, Button, CheckBox, etc.
18. Difference between context menu and popup menu?
A context menu appears when user press long click on the view. A popup Menu is a list menu that appears vertically on the view.
19. Difference between getContext(), getApplicationContext(), getBaseContext()?
getContext() – Returns the context of current activity. getApplicationContext() – Used to return the context for the activities running in an application. getBaseContext() – Used to access context of one activity from another context.
20. What is a Resource File?
The res folder in Android project explorer have all type of resources such as image, video, logo icons and values for the application.
It is very important to take a training for Android to get a confidence to attend all interviews. So, you can plan to join for an android app development training in Kochi to know more in depth about the tips and tricks related to the development process. You can get the confidence to build your own app, along with the latest technologies that will help you improve your coding style. We are one of the android training center in Kochi, and we would be delighted to assist you in improving your Android career.
0 notes
Text
What is 'Context' on Android?
original source : http://stackoverflow.com/questions/3572463/what-is-context-on-android/3572553#3572553
Definition of Context::
Context represents environment data
It provides access to things such as databases
Simpler terms ::
Consider Person-X is the CEO of a start-up software company.
There is a lead architect present in the company, this lead architect does all the work in the company which involves such as database, UI etc.
Now the CEO Hires a new Developer.
It is the Architect who tells the responsibility of the newly hired person based on the skills of the new person that whether he will work on Database or UI etc.
Simpler terms ::
It's like access of android activity to the app's resource.
It's similar to when you visit a hotel, you want breakfast, lunch & dinner in the suitable timings, right?
There are many other things you like during the time of stay. How do you get these things?
You ask the room-service person to bring these things for you.
Here the room-service person is the context considering you are the single activity and the hotel to be your app, finally the breakfast, lunch & dinner have to be the resources.
Things that involve context are:
Loading a resource.
Launching a new activity.
Creating views.
obtaining system service.
Context is the base class for Activity, Service, Application .... etc
Another way to describe this: Consider context as remote of a TV & channel's in the television are resources, services, using intents etc - - - Here remote acts as an access to get access to all the different resources into foreground.
So, Remote has access to channels such as resources, services, using intents etc ....
Likewise ..... Whoever has access to remote naturally has access to all the things such as resources, services, using intents etc
Different invoking methods by which you can get context
getApplicationContext()
getContext()
getBaseContext()
or this (when in the activity class)
0 notes