android mindtree questions and answers paper 622 - skillgunNote: Paper virtual numbers may be different from actual paper numbers . In the page numbers section website displaying virtual numbers .
Have u worked on AIDL?
Only if one is working on binder services, then only there is a fair chance of working on AIDL. IPC (Inter Process Communication) in android happens through kernel level Binder driver.
AIDL (Android Interface Definition Language) is a mechanism which internally uses Binders to access or to bind services of other applications.
Binder is an efficient way to do IPC when compared to serialization, thats why AIDL adopts Binder.
When a client application binds a remote service (which is in other application), that service will return an object using which client can call remote methods.
Since both client and service are in different applications, client would not know the type of object which is going to be returned. This is where AIDL
will be useful.
Steps to implement AIDL in service side (server side):
1. create aidl file, which contains function declarations which you want to expose to the client.
2. implement interface stub method in your service file.
3. create an object for stub and return it as binder object to client
steps to implement AIDL in client side:
1. implement ServiceConnection object, and get the binder object in
onServiceConnected() method, using aidl file interface name which was exposed by service.
2. Start calling remote methods by using that object.
Why we don’t give min sdk version as 1?
There are very negligible number of devices who runs version 1 of android. It is almost deprecated completely. Setting min sdk is to make sure that an application is reaching wide range of users. As of today it will be sufficient to reach major number of users if we set min sdk version as 2.2.
What are the basic uses of manifest file?
Every application will contain one manifest file which contains important information about the application which system must know before it can run the application. 1. It contains package name of your application. 2. it contains various components used in the application like how many activities, services, receivers and content providers available in your application. 3. It contains all permissions required to run the application properly. 4. It contains minimum level of api required to run this application. 5. It lists all the libraries required to run the application. etc.
What is the use of registering broadcast receiver in manifest file?
Registering a receiver in manifest file makes sure that our receiver will be triggered even if our application is not running currently. For example when a new incoming SMS comes it should be handled by Messaging application even if it is not running currently. In this case programmer has to register the receiver in messaging application's manifest file to respond to incoming sms.
Commands to write or create .apk file?
1. use javac to compile your java files
2. use dx tool to convert all .class files to single dex file
3. use aapt tool or apkbuilder tool to generate .apk file, which contains manifest, .dex, and res.
.apk is equivalent to .jar in java.
aapt tool and dx tools are in android-sdk/platform-tools.
4. sign the apk file by using jarsigner tool of jdk/bin
5. zipalign your signed apk by using zipalign tool of android-sdk/tools
Can we create all ui coding in activity without using xml?
Ui can be completely created through programming. But that is not recommended. There should be clear separation between design and the logic. That is the reason why android has given res folder to create all the designs like layouts, menus, icons, and styles. If project demands some dynamic changes to the UI, which can't be done in the xml files, then programmer can use any View or ViewGroup classes to design the UI through programming.
lLayout = new LinearLayout(this);
tView = new TextView(this);
tView.setText("Hello, This is a view created programmatically!");
Life cycle of activity and Fragments?what is Fragment?
When I run any application where fragments are there which method will be called first?
Just like Activities has life cycle methods, similarly fragments also have their life cycle methods. When we load a fragment first method to be called is onAttach(), followed by onCreate(), which is followed by onCreateView(). Generally programmers will not implement onAttach() method. onCreate() is where we will initialize all the variables which are used in the fragment. onCreateView() is where we will inflate or load the xml file of our fragment and return it to the parent (activity).
Can we have fragments without activity?
It is not possible to have fragment with out an activity. Fragments are part of activity. Fragments always lies with in the activity. An activity can exist without a fragment where as fragment with out an activity is not possible. You can assume fragment like a thread and activity is like a process, where threads are always part of a process. Every fragment will contribute its own UI to the parent activity.
Tell me different IDEs other than eclipse?
Android can be developed by using below IDEs:
Android Studio which is based on IntelliJ
As of now plugins are up to date for Eclipse.
But soon Android Studio is going to be the official IDE for android development.
Asked about memory leakage?How to handle it
To fix memory leaks, first we should know if our application is leaking any memory. For that use Logcat and check for GC messages and observe if free memory is going down. To understand this you can rotate your phone for couple of times and observe gc messages in logcat if free memory is going down. If you see that free memory is going down, that is an indication of memory leak. To fix memory leaks you can use MAT(memory analyzer tool) of eclipse. Before doing that you should create a hprof file which contains the memory status of your application. Open up hprof file in the memory analyzer tool to check for dominator tree and find out what is causing for your memory leak. Note: 70-80% of the memory will leaked by bitmap images, so be careful while using them, and try to avoid un necessery static pointers to them to avoid memory leaks. For more on this, checki https://www.youtube.com/watch?v=_CruQY55HOk
Back To Top