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 services interview questions and answers

Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
3
What is not true about a binder service in android?
  1. It is a client server model, where binder service will act as a server which responds to client requests with some data.
  2. A bounded service can also be a started service.
  3. onBind() function will be called every time a client binds to the binder service.
  4. A serviceconnectionobject has to be passed to bindservice to monitor if connection is established between client and server.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
5
What is the life cycle of a started service?
  1. oncreate -> onstart() -> onBind() -> onUnbind() -> onDestroy()
  2. oncreate -> onstart() -> onDestroy()
  3. oncreate -> onstartCommand() -> onDestroy()
  4. oncreate -> onstartCommand() -> onBind() -> onUnbind() -> onDestroy()
Show Answer
Share Facebook gmail Twitter
6
How to achieve security for services programmatically, in such a way that your service should not get triggered from outside applications?
  1. Don't give any intent-filters for your service tag [or] put exported="false" in service tag [or] LocalServiceManager
  2. Don't give any intent-filters for your service tag [or] LocalServiceManager
  3. Don't give any intent-filters for your service tag [or] put imported="false" in service tag [or] LocalServiceManager
  4. put exported="false" in service tag [or] LocalServiceManager
Show Answer
Share Facebook gmail Twitter
7
To do some back ground functionality in an activity, which is better ? thread or service?
  1. thread is better as long as thread is closely related with your UI and as long as programmer make sure that cleaning and creation of thread is done properly.
  2. it is better to use services with thread, because threads in activity will have less priority compared to thread in a service in case if that activity is in background or stopped state. more over in case of low memory if it kills thread in activity, there is no way that android will recreate it. all these disadvantages are overcome in services with android.
  3. you can either use option 1 or option 2, based on your requirement. But most of the times it is better to use option 2.
  4. Both thread and service are back ground components, so you can use either of them.
Show Answer
Share Facebook gmail Twitter
8
can I start a service from worker thread?
  1. You can start service from any where, but still oncreate, onstartcommand runs in main thread only.
  2. You can start service from any where, but after that oncreate, onstartcommand runs in that worker thread. so you have to make sure that you shouldn't touch UI from those functions.
  3. No, it is illegal to do so. it will throw run time exception and program will be crashed.
  4. it gives compile time error if we try to do so.
Show Answer
Share Facebook gmail Twitter
9
Update UI or toast from IntentService : What will happen if you try to touch UI or try to print a toast message from onHandleIntent() function of IntentService class ?
  1. it works perfectly fine. we can touch UI from IntentService class.
  2. you can't touch UI from it, or toast message will not be printed.
  3. it behaves weirdly, either toast message may not appear or it appears and will be never removed. this happens because other thread is touch ui with out informing to main thread.If you try to touch other UI components, it will crash.
  4. none of the above.
Show Answer
Share Facebook gmail Twitter
10
How to move a service to foreground?
  1. A service always runs in background, so there nothing like foreground service.
  2. call startForeground(int id, Notification notification);
  3. call startService(Intent intent)
  4. none
Show Answer
Share Facebook gmail Twitter
11
What is not true about a binder service?
  1. There may be situations where both client & server will be in the same process.
  2. In case if client is in different process and service(Server) is in different process, then we should always use aidl to implement it.
  3. Option 2 can also be implemented with Messenger class in case if we want to write single threaded service.
  4. Binders internally uses Parcels.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
13
If I want to create a binder service which supports multi threaded architecture, then which of the below concepts i have to use?
  1. Use only Binder class.
  2. Use Binder class with Messenger.
  3. Use .aidls and implement the stub.
  4. we can use either option2 or option3.
Show Answer
Share Facebook gmail Twitter
14
What is true about a binder service?
  1. bindservice() function is an asynchronous call. it returns only after connection is established between client and server.
  2. onBind() function will be called every time a client calls bindservice function.
  3. onServiceDisconnected() function of ServiceConnection object will be called once a client says unbindeservice().
  4. bindService() function is an asynchronous call which returns immediately. after returning, connection will be established after some time.
Show Answer
Share Facebook gmail Twitter
15
When implementing a bounded service, where client & server are in same process, which of the below functionalities I can do in inner Binder class?
  1. Binder extended class can contain public methods, which can be accessed by client.
  2. Binder extended class can return the object of outer service class, whose public functionalities can be accessed by client.
  3. Binder extended class can return any other class's object of Service, whose public functionalities can be accessed by client.
  4. select 1 if only option1 is true, 2 if both 1&2 are correct, 3 if all 3 are correct, else select 4.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :