important Android interview questions and answers
Explain the build process in Android?
A: The build process in Android involves three steps
- The first step consists of the compilation of the resources folder using the Android Asset Packaging Tool (AAPT). These are compiled into a single class file known as R.java, which only holds constants.
- In the second step, the java source code needs to be compiled to .class files using javac, which are then converted to Dalvik bytecode using the ‘dx’ tool, which is one of the tools in the software development kit. The final output file is classes.ex.
- In the third and final step, the Android apkbuilder is required to take all the inputs and build the Android Packaging Key (APK) file.
A: Below is a list of the most popular programming languages that can be used to develop applications in Android
- Java: Java, the most popular programming language in the world has always been a starting point for new developers and used by the majority of people who work with Android development.
- Kotlin: Kotlin is a relatively new, modern, safe and object-oriented cross-platform programming language. When Android studio 3.0 was released in Oct 2017, Kotlin was announced as the official programming language for Android. Many popular applications such as Trello, Square and Corda have since then shifted to Kotlin.
- C#: Using the C# language developers can build native iOS and Android mobile applications.
- Python: Python has emerged as one of the most popular programming languages in recent times. A dynamic and object-oriented programming language, Python is very popular in machine learning.
Other languages which can be used in Android are C++, HTML 5.
What is meant by responsive design?
A) Its a layout that adjust automatically depending on screen size.
What is URLConnection?
A) An URLConnection used to send and receive data over the web. Data may be of any type and length. This class may be used to send and receive streaming data whose length is not known in advance.
What is logging (Logcat)?
A) The logging (Logcat) system provides a mechanism for collecting and viewing system debug output.
3) What is the use of an activityCreator?
Ans. An activityCreator is the first step towards the creation of a new Android project.
4) What is AndroidManifest.xml
? Android Official
Yes, they can. However, needless to say, it doesn’t happen just like that.
For the two apps to hold a shared Linux ID, they would both have to have signed with the same certificate. In addition to that, they would then also share the same VP.
Name the four Java sensor classes.
Android uses four specific Java classes that are based on sensors. These are as follows: Sensor, SensorEvent, SensorEventListener, and SensorManager.
What is the difference between SDK and NDK?
- NDK is a toolset that lets you embed components that make use of native code in your Android applications.That means you have to write portion of code in C/C++ just to achieve the speed.
- SDK (software development kit) is a set of development tools used to develop applications for Android platform. Applications are written using java and run on Dalvik. That means it will be slower than what you could achieve with C/C++.
What is Software system?
A) System of intercommunicating components based on software forming part of the computer system
What is Library module?
A) Module that contains shareable Android source code and resources that developer can reference in Android projects
What is GAE (Google App Engine)?
A) A PaaS cloud computing platform for developing and hosting web applications in Google-managed data centers
How can two Android applications share same Linux user ID and share same VM?
A: The applications must sign with the same certificate in order to share same Linux user ID and share same VM.
What is PaaS?
A) A category of cloud computing services that provides a platform allowing customers to develop, run, and manage applications without the complexity of building and maintaining the infrastructure
What is the use of android:sharedUserId?
Application with the same user ID can access each other's data and, if desired, run in the same process.
A) A mobile service developed by Google that enables third-party application developers to send notification data or information from developer-run servers to applications
What is the purpose of running zipalign?
The benefit is a reduction in the amount of RAM consumed when running the application.
Reference
http://developer.android.com/tools/help/zipalign.html
What is the purpose of running ProGuard?
- smaller sized .apk file
- more difficult to reverse engineer.
Reference
http://developer.android.com/tools/help/proguard.html
What is .idea/ directory?
A) Directoty for IntelliJ IDEA settings
What is app/ directory?
A) A folder that contains application module directories and files
What is lint tool?
Reference
http://developer.android.com/tools/help/lint.html
What is gradle/ directory?
A) A folder that contains the gradle-wrapper files
What is multiple APK support in Google play
Reference
http://developer.android.com/google/play/publishing/multiple-apks.html
What is .gitignore?
A) Specifies the untracked files that Git should ignore
What is the current size limit for an application in Google play?
What is build.gradle?
A) Customizable properties for the build system
How to upload apks with a size of more than that is mentioned above?
What is gradle.properties?
A) Project-wide gradle settings
74) What is gradlew?
A) Gradle startup script for Unix
75) What is gradlew.bat?
A) Gradle startup script for Windows
76) What is local.properties?
A) Customizable computer-specific properties for the build system, such as the path to the SDK installation
77) What is .iml directory?
A) Module file created by IntelliJ IDEA to store module information
78) What is settings.gradle?
A) Specifies the sub-projects to build
79) What is build/ directory?
A) Directory that contains build folders for the specified build variants
80) What is libs/ directory?
A) Directory that contains private libraries
What is src/ directory?
A) Directory that contains the stub Activity file and other source code files
82) What is androidTest/ directory?
A) Directory that contains the instrumentation tests
83) What is main/java/com.<project>.<app>?
A) Directory that contains Java source code for the app activities
84) What is main/jni/ directory?
A) Directory that contains native code using the JNI
85) What is Android NDK?
A) A toolset that allows you to implement parts of your app using native-code languages
86) What is IDL (interface definition language)?
A) A specification language used to describe a software component’s API
87) What is main/res/ directory?
A) Directory that contains application resources, such as drawable files, layout files, and string values
88) What is anim/ directory?
A) Directory for XML files that are compiled into animation objects
89) What is color/ directory?
A) Directory for XML files that describe colors
90) What is drawable/ directory?
A) Directory for bitmap files (PNG, JPG, or GIF), 9-Patch image files, and XML files that describe Drawable shapes or Drawable objects that contain multiple states
A) Result Code
142) Which of the following is layout that you can use in a window in an Android application?
A) FrameLayout
143) How do you access the string resource stored in the strings.xml file?
A) You can use the getResources() method
144) Which of the following methods is used to return a View from a layout file given the ID of the View?
A) .findViewById(int id)
145) Which of the following used to detect when a user clicks or taps on a button?
A) OnClickListener
146) What is contained within the manifest xml file?
A) The permissions the application requires Correct
147) Android: Which attribute will be used in XML if the Java code needs a reference to View??
A) android:id
148) How do you programmatically determine whether a RadioButton is checked?
A) You should check the isChecked() method
How to set data for a Spinner control?
A) Use method setAdapter()
153) In auto-generated code of an Android app, what is R class?
A) Contains IDs of the project resources
154) How does Android system manage activity’s life cycle?
A) Via system activity stack
155) What is the correct HTML5 element for playing video files?
A) <video>
156) Does CSS support to detecting device size and orientation?
A) True
155) What is NOT correct about Controller in Sencha Touch?
A) Responsible for responding to events that occur within your app
156) Which file is entry point for Sencha Touch app?
A) app.js
157) Which doctype is correct for HTML5?
A) <!DOCTYPE html>
158) Which kind of application when creating with Sencha Touch?
A) Hybrid app
159) Graphics defined by SVG is in which format?
A) XML
160) In HTML5, onblur and onfocus are?
A) Event attributes
170) Which Android File API to create a file?
A) openFileOutput()
171) Does HTML5 native support for local storage?
A) True
How to check if browser supports web storage?
A) Check if typeof(Storage) !== “undefined”
173) How to apply stylesheet with HTML element by id?
A) #id
174) How to get the form data in Sencha Touch?
A) getFormInstance().getValues();
175) Which permission needed in order to use MapActivity?
A) <uses-permission android:name=”android.permission.INTERNET” />
Do we need API key for displaying Google Maps in Android?
A) yes
How to set layout’s attribute programmatically in android?
A) Use LayoutParams class
187) What is base of all Sencha Touch component?
A) ExtComponent
188) Which method to display a dialog?
A) show()
189) How to change the main color of Sencha Touch application?
A) Change the $base-color variable in app.scss
190) Which activity class do you need to inherit to show Google map?
A) MapActivity class
Which class do we use for listening location update?
A) LocationManager class
What is NOT correct about Store in Sencha Touch?
A) Load data via a Proxy
203) How to define a new Sencha Touch class?
A) Use Extdefine()
204) If the action is ACTION_CALL. what the data field would be?
A) URI with the number to call
205) Android MapActivity is?
A) Base class with code to manage the boring necessities of any activity that displays a MapView
What are location providers in Android?
A) GPS & Network
What is NOT correct about Store in Sencha Touch?
A) Load data via a Proxy
203) How to define a new Sencha Touch class?
A) Use Extdefine()
204) If the action is ACTION_CALL. what the data field would be?
A) URI with the number to call
205) Android MapActivity is?
A) Base class with code to manage the boring necessities of any activity that displays a MapView
What are location providers in Android?
A) GPS & Network
In Android, which is two location providers that you can use to obtain your position data?
A) LocationManager.GPS_PROVIDER and LocationManager.NETWORK_PROVIDER
254) In Android, the process technical to convert an address into its latitude and longitude is called?
A) Geocoding
255) What happen if the latitude is less than -90 or greater than 90?
A0 It returns an IllegalArgumentException
256) Given the following statements using openFileOutput function to store data into a file in Android?
A) The created file can be accessed by all the other applications at the same time.
What types of permissions exists?
A) Normal permission – Permission that wont directly risk the user’s privacy
Dangerous permission – can give the app access to the user’s confidential data.
what is Bundle in Android?
Ans: a Bundle is an object . It is used to pass data between Activities. The values are passed and Mapped to String keys. Which are used to retrieve the values from Key.
What is an Application class?
A) An Application class is a base class in your Application starts before all other classes like Activities or services are called. You can maintain your application's global state here. While it is NOT mandatory that you need to extend Application class, you can do so by providing your own implementation by creating a subclass and specifying the fully-qualified name of this subclass as the "android:name" attribute in your AndroidManifest.xml's tag.What is Dalvik?
Dalvik is a register-based Virtual Machine (VM). Every Android app runs in its own process with its own instance of the Dalvik VM.
Note: Dalvik was entirely replaced by ART in Android 5.0 Lollipop.
What is ART?
ART (Android Runtime) is the new runtime environment for Android apps. ART improves the execution efficiency by using AOT (Ahead-of-Time) compilation.
What is the “UI thread”?
An Android app runs in its own process and can use multiple threads. The thread that the app will be executed upon, most of the time, is called the “main thread” or the “UI thread”.
What is Instant Run?
Instant Run has the intention to increase the development speed of Android apps. Instead of rebuilding the whole app, Android is trying to patch the existing app on the Android device to reflect your changes.
What is an Android manifest file?
Every Android app must have an AndroidManifest.xml file in its root directory. The AndroidManifest.xml file provides essential information about the application to the Android system, which the system must have before it can run any of the application’s code.
Background: It contains information about:
- the Java package of the application
- app components like activities, services, broadcast receivers and content providers
- necessary permissions
What is ADB?
Android Debug Bridge (adb) is a command-line tool that lets you communicate with an Android device. It provides a variety of device actions, such as installing and debugging apps.
For doing some job like Application Update or where you want your CPU keeps running before the device go to sleep so we can use Power Manager service. This service will give you one feature like WakeLock that allows our application to control the power state. if we need to want to keep the screen on in our activity, we need to use FLAG_KEEP_SCREEN_ON. As mention below:
permission android:name="android.permission.WAKE_LOCK" />
We will write below code in activity.java
// Get an instance of the SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); // Get an instance of the PowerManager mPowerManager = (PowerManager) getSystemService(POWER_SERVICE); // Get an instance of the WindowManager mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); mWindowManager.getDefaultDisplay(); // Create a bright wake lock mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass() .getName());
For protecting the privacy of an Android user we are using Permission concept in android. When the application is trying to access user data like contact, Gallery they requesting permission. Depending on the feature, the system might grant the permission automatically or might prompt the user to approve the request
UsesPermission: Specifies system permission that the user must grant in order for the app to operate correctly. Permissions are granted by the user when the application is installed.
<uses-permission android:name="string" android:maxSdkVersion="integer" />
Permission: To enforce your own permissions, you must first declare them in your AndroidManifest.xml using one or more <permission> tags..Declares a security permission that can be used to limit access to specific components or features of this or other applications.
<permission android:name="com.me.app.myapp.permission.DEADLY_ACTIVITY" android:label="@string/permlab_deadlyActivity" android:description="@string/permdesc_deadlyActivity" android:permissionGroup="android.permission-group.COST_MONEY" android:protectionLevel="dangerous" />
For this, we can modify our build Gradle file of the application. In Gradle file we will add code for adding build type and build flavour like below:
buildTypes { debug { applicationIdSuffix '.debug' versionNameSuffix '-DEBUG' resValue "string", "app_name", "AppName debug" } release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release zipAlignEnabled true resValue "string", "app_name", "AppName" } }
Fused location provider tries to get the best possible location which is certainly the location data from GPS. If you want location from your mobile network put the following permission in your manifest.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>The fused location provider is one of the location APIs in Google Play services. It manages the underlying location technology and provides a simple API so that you can specify requirements at a high level, like high accuracy or low power. It also optimizes the device's use of battery power
Comments
Post a Comment