Pages

Gin Rummy Indian Rummy Nine Men's Morris and more Air Attack

Saturday, 5 March 2016

Advanced Android Interview Questions and Answers 3

(PREVIOUS (Advanced Android Interview Questions and Answers 2

1. How to verify that there is an activity available that can respond to the intent?

SHOW/HIDE ANSWER
Using package manager.
PackageManager packageManager = getPackageManager();
List activities = packageManager.queryIntentActivities(intent,
        PackageManager.MATCH_DEFAULT_ONLY);
boolean isIntentSafe = activities.size() > 0;

2. How to get result from an Activity?

SHOW/HIDE ANSWER
Call startActivityForResult() with a request code
Implement onActivityResult(int requestCode, int resultCode, Intent data) on your activity
A result code specified by the second activity. This is either RESULT_OK if the operation was successful or RESULT_CANCELED if the user backed out or the operation failed for some reason

3. What is the use of android:sharedUserId?

SHOW/HIDE ANSWER
If android:sharedUserId is set same for two applications which are signed with the same certificate then both the application will share the same user ID.
Application with the same user ID can access each other's data and, if desired, run in the same process.

4. How to convert an Android application project to an Android library project with gradle build system?

SHOW/HIDE ANSWER
In your app build.gradle file change,
apply plugin: 'com.android.application'
to
apply plugin: 'com.android.library'
For a libary project you wont need applicationId, versionCode and versionName

5. What is the purpose of running zipalign?

SHOW/HIDE ANSWER
Running zipalign ensure that all uncompressed data(images or raw files) starts with a particular alignment(4-byte boundaries) relative to the start of the file.
The benefit is a reduction in the amount of RAM consumed when running the application.
Reference
http://developer.android.com/tools/help/zipalign.html

6. What is the purpose of running ProGuard?

SHOW/HIDE ANSWER
The ProGuard tool shrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names. Benefits are,
  • smaller sized .apk file
  • more difficult to reverse engineer.

Reference
http://developer.android.com/tools/help/proguard.html

7. What is lint tool?

SHOW/HIDE ANSWER
Is a static code analysis tool that checks your Android project source files for potential bugs and optimization improvements for correctness, security, performance, usability, accessibility, and internationalization.
Reference
http://developer.android.com/tools/help/lint.html

8. What is multiple APK support in Google play

SHOW/HIDE ANSWER
A Feature on Google Play that allows you to publish different APKs for your application that are each targeted to different device configurations.
Reference
http://developer.android.com/google/play/publishing/multiple-apks.html

9. What is the current size limit for an application in Google play?

SHOW/HIDE ANSWER
100 MB at the time of writting this answer.

10. How to upload apks with a size of more than that is mentioned above?


11. What is Support Library?

SHOW/HIDE ANSWER
A set of code libraries that provide backward-compatible versions of Android framework APIs as well as features that are only available through the library APIs.
Reference
http://developer.android.com/intl/ja/tools/support-library/index.html

12. What is DDMS?

SHOW/HIDE ANSWER
Is a debugging tool its full name is Dalvik Debug Monitor Server (DDMS).
It some of the features are,
  • provides heap usage for a process
  • tracks memory allocation of objects
  • provides thread information
  • android file system exploring
  • method profiling
  • network trafic analysis
  • emulates phone operation and location

Reference
http://developer.android.com/intl/ja/tools/debugging/ddms.html

13. What is the differece between Serializable and Parcelable?

SHOW/HIDE ANSWER
Serializable is a standard Java interface where as Parcelable is an Android specific interface.
Parcelable is faster than Serializable. Serializable is easier than a Parcelable to implement.

14. What are the different ways to store data?

SHOW/HIDE ANSWER
  • Sqlite Database
  • Internal Store
  • External Store
  • Network Connection
  • Shared Preferences

15. What are different ways to process a task in a background thread(other than main(UI) thread) in Android?

SHOW/HIDE ANSWER
  • Using Java Thread/Runnable classes
  • Using AsyncTask
  • Using Loaders(AsyncTaskLoader, etc.)
  • Using HandlerThread/Looper/Handler
  • Using ThreadPool : http://developer.android.com/training/multiple-threads/run-code.html
  • Using IntentService

16. What is data binding?

SHOW/HIDE ANSWER
It helps in binding values of an object directly to views in the layout. If the data changes it can update the views.
Reference
http://developer.android.com/tools/data-binding/guide.html

17. What causes an ANR?

SHOW/HIDE ANSWER
  • No response to an input event (such as key press or screen touch events) within 5 seconds.
  • A BroadcastReceiver hasn't finished executing within 10 seconds.

Reference
http://developer.android.com/training/articles/perf-anr.html

18. In which thread does an IntentService performs it's task?

SHOW/HIDE ANSWER
Not in the main thread but in a worker thread

19. What is doze mode?

SHOW/HIDE ANSWER
Device enters doze mode if, an user leaves it unplugged and stationary for a period of time, with the screen off. In doze mode network access and and CPU-intensive services are restricted.
Periodically, the system exits Doze for a brief time to let apps complete their deferred activities.
Systems exits doze mode if user wakes the device by moving it, turning on the screen, or connecting a charger.

Reference
http://developer.android.com/training/monitoring-device-state/doze-standby.html

20. What is App Standby?

SHOW/HIDE ANSWER
An application goes to App Standby mode if the user does not touch the app for certain period of time and none of the following conditions happened:
  • you explicitly launch the app
  • The app has a process currently in the foreground
  • The app produces a notification

When in standby mode, network access and background sync jobs are restricted.
When user plugs the device into a power supply, system releases apps from standby mode.

Reference
http://developer.android.com/training/monitoring-device-state/doze-standby.html

No comments:

Post a Comment