Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Android Interview Questions

1. Main components of android 
2. What are Activities Life cycles, explain with an Example? 
3. Explain remote service. 
4. Explain pending intent. 
5. What is advantage of pending intent over intent? 
6. Explain Broadcast Receivers with an Example 
7. Explain content provider and content resolver. 
8. Explain content provider and content resolver with help of a sample code. 
9. What is .apk? How is it generated? 
10. What is .aidl file? Can we use any different name instead of .aidl and create interface using any commands? 
11. What are threads? 
12. What are the two ways of implementing threads and which is the better one? 
13. startBroadcast(), startOrderBroadcast() and startStickyBroadcast() 
14. What are the different states of a thread? 
15. Explain Widget in android? 
16. Explain about android runtime environment. 
17. What is a Launcher? 
18. Explain init.c with respect to Dalvik Virtual Machine? 
19. Explain Services?Different type of services? 
20. Explain aidl interface and its implementation? 
21. Explain remote service with examples? 
22. Explain intent filter and intents? 
23. If an activity ‘A’ starts activity ‘B’ and ‘B’ starts another activity ‘C’,what is the method to call to finish all activities? 
24. Explain startService() and bindService()? 
25. What is content Resolver?Is it a wrapper Class? 
26. What is the difference between content receiver and content Provider? 
27. Explain Implicit and explicit intent and its flow? 
28. Explain Activity Lifecycle 
29. Explain Service Lifecycle? 
30. Local service and remote service? 
31. Explain AIDL concept? 
32. What are Broadcast Receivers and how to register them statically and ynamically? 
33. What are Content providers and how do we access the data? 
34. What adb commands you have used? 
35. What is manifest file? 
36. What is category,action and data in intents and how they work? 
37. Shared preference - how to get it? 
38. Android listview and adapters 
39. How android manage applications on low memory? 
40. Pass data across different applications 
41. How to start Activity of another application 
42. How to use Bundles and pass aprameters? 
43. What all are mentioned in AndroidManifest.xml 
44. How to make an Activity to launch at start 
45. Can we have two launcher Activities? 
46. How to make onCreate execute multiple times? 
47. Explain Recievers? 
48. How to get intent in a newly launched Activity 
49. How to troubleshoot when adb is not detecting device 
50. List some adb commands 
51. If I want to save the state of activity,in which method of lifecycle , I have to store? 
52. When OnsaveInstantState method will be called? 
53. Difference between service and broadcast-receiver? 
54. What is Pending Intent
55. Difference between Activity and view
56. What is Shared Preference and difference with normal preference
57. What are the killable methods in Activity life cycle?
58· Can Activity run in background? 
59· What is layout and what are the different types of layouts? 
60· What is the difference between linear and relative layout? 
61· Can linear layout be nested in relative layout and vice versa? 
62· How to position the layout? 
63. Diff b/w SimpleCursorAdapter and CursorAdapter 
64. What is Handlers and its implementation. 
65. How Library and frameWork layer communicating. 
66. What is JNI.How it works. 
67. Difference between cursor adapter and Simple cursor adapter. 
68. How do you debug your application.

Using SMS in your Application

Android offers full access to SMS functionality from within your applications with the SMSManager. Using the SMS Manager, you can replace the native SMS application or create new applications that send text messages, react to incoming texts, or use SMS as a data transport layer. 

Sending SMS Messages:

SMS messaging in Android is handled by the SmsManager. You can get a reference to the SMS Manager using the static method SmsManger.getDefault, as shown in the snippet below.

SmsManager smsManager = SmsManager.getDefault(); 


To send SMS messages, your applications require the SEND_SMS permission. To request this permission, add it to the manifest using a uses-permission tag, as shown below: 

<uses-permission android:name=”android.permission.SEND_SMS”/>

Sending Text Messages:

To send a text message, use sendTextMessage from the SMS Manager, passing in the address (phone number) of your recipient and the text message you want to send, as shown in the snippet below: 

String sendTo = “5551234”;
String myMessage = “Sample SMS Text!”; 
smsManager.sendTextMessage(sendTo, null, myMessage, null, null); 

The second parameter can be used to specify the SMS service center to use; entering null as shown in the previous snippet uses the default service center for your carrier. 

The final two parameters let you specify Intents to track the transmission and successful delivery of your messages. 


To react to these Intents, create and register Broadcast Receivers. 

Tracking and Confirming SMS Message Delivery:
To track the transmission and delivery success of your outgoing SMS messages, implement and register Broadcast Receivers that listen for the actions you specify when creating the Pending Intents you pass in to the sendTextMessage method. 

The first Pending Intent parameter, sentIntent, is fired when the message is either successfully sent or fails to send. The result code for the Broadcast Receiver that receives this Intent will be one of: 

❑ Activity.RESULT_OK to indicate a successful transmission. 
❑ SmsManager.RESULT_ERROR_GENERIC_FAILURE To indicate a nonspecific failure. 
❑ SmsManager.RESULT_ERROR_RADIO_OFF When the connection radio is turned off. 
❑ SmsManager.RESULT_ERROR_NULL_PDU To indicate a PDU failure. 


Listening for SMS Messages:

When a new SMS message is received by the device, a new broadcast Intent is fired with the android.provider.Telephony.SMS_RECEIVED action.
For an application to listen for SMS Intent broadcasts, it first needs to be have the RECEIVE_SMS permission granted. Request this permission by adding a uses-permission tag to the application manifest, as shown in the following snippet: 

<uses-permission android:name=”android.permission.RECEIVE_SMS”/> 


The SMS broadcast Intent includes the incoming SMS details. To extract the array of SmsMessage objects packaged within the SMS broadcast Intent bundle, use the pdu key to extract an array of SMS pdus, each of which represents an SMS message. To convert each pdu byte array into an SMS Message object, call SmsMessage.createFromPdu, passing in each byte array as shown in the snippet below: 

Bundle bundle = intent.getExtras(); 
if (bundle != null) 

          Object[] pdus = (Object[]) bundle.get(“pdus”); 
          SmsMessage[] messages = new SmsMessage[pdus.length]; 
          for (int i = 0; i < pdus.length; i++) 
                  messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); 


Each SmsMessage object contains the SMS message details, including the originating address (phone number), time stamp, and the message body. 

To listen for incoming messages, register the Broadcast Receiver using an Intent Filter that listens for the android.provider.Telephony.SMS_RECEIVED

Android Multimedia: Media Player States





  • Playback control of audio/video files and streams is managed as a state machine. 
  • The following diagram shows the life cycle and the states of a Media Player object driven by the supported playback control operations. 
  • Media Player has several internal states and can be changed by different operations. 
  • Media Player is a controller class that has a lot of low level function calls which directly invoke the functions in the native media framework library; it can handle not only video but audio content as well;
Player States:
  • Idle: When the Media Player object is created using new or after reset () is called, it is in idle state. Call the Media Player constructor to create the object; the Media Player object is in idle state when created; 
                         a) MediaPlayer mp = new MediaPlayer (); 
                              It creates new MediaPlayer object, and we can interact with the player object. 
                             After we need to initialize the player with SetDataSource (...) method. 
                         b) public static MediaPlayer create (Context context, Uri uri): 
                              It creates a MediaPlayer for a given Uri. On success the prepare () also called 
                              no need to call prepare again. 
                              After successful of create we can give command play ().                                
                              Here the argument uri is the Uri from which to get the datasource. 
                         c) public static MediaPlayer create (Context context, int resid) 
                             It create a MediaPlayer for a given resource id, on success prepare () also 
                             called, no need to call prepare again. After successful of create we can give 
                             command play (). 
                             Here the resid is the resource to use as the datasource                         
                         d) public static MediaPlayer create (Context context, Uri uri, SurfaceHolder 
                             holder) 
                             It create a MediaPlayer for a given Uri, and uses the holder to render the 
                             video, onsuccess it calls the prepare() method. After successful of create we 
                             can give command play (). 
                    Note: After b,c,d calls the player in “Prepared State”, we can give play command 
                              after successful completion of these methods. 


  • End: After release () is called it is in End state.                                                                         After calling release on MediaPlayer it will be in End state. After release, the object is no longer available. We can call this (release) method in any state of the player. 
  • Initialized: calling setDatsource () method transfers a Media player objects in the idle state to initialized state. 
          Media Player class has several setDataSource () signatures to accept different content 
          type than URI. After this call, the Media Player object is in “Initialized” state; 

          After SetDataSource we can prepare the player in two ways 
                   1) Prepare(): If it is a local file or raw file with the project resource then we can give 
                        prepare command. We can call prepare on player if player in initialized or 
                        Stopped state only. 
                   2) PrepareAsync (): If it is a URL and we need to stream the data from network 
                        and play that data in that case we need to give prepareAsync () command for non 
                        blocking functionality. We can call prepare on player if player in initialized or 
                        Stopped state only. 


  • Preparing: If we call the prepareAsync (), now the player is in preparing state. After the required buffer gathered with it will go to prepared state and it will call the onPrepared listener attached to the player object. And the player currently in Prepared State. 
  • Prepared: If we call prepare (), player is in Prepared state. 
           Media Player object must first enter the Prepared state before playback can be started. 
           In this state, the Media Player object can be operated to play, pause and stop, etc. 

  • Playing: The playback starts after start () of the Media Player object is invoked inside of the onPrepared () callback function. The Media Player object is at the “Started” state now and can be paused and stopped. 
  • Stop: Call stop () of Media Player to stop the playback. This sets the object to the “Stopped” state. Once in the “Stopped” state, the Media Player must be prepared again in order to play. 
          We can give stop command to the player if the player current state is Prepared, Started, 
          Stopped, Paused, and Playback Completed. 
  • Paused: We can give the pause command on the player if its current state is Started or Paused. 
  • Playback Complete: If the Player completes the playing of the given file, the player current state is PlaybackCompleted. In this state we can restart the player using start () command. 
  • Error: If any errors occurred while preparing or playing the player state will be in Error state. It will call the OnError listener attached to the player.

Android: Multimedia Interview Questions

1) Explain the android architecture?
2) Explain the code flow for audio playback scenario and video playback scenario?
3) Explain the state diagram of media player object?
4) What is MM framework and explain about open core and stage fright?
5) Diff b/w Open core and Stage fright?
6) Explain Stage fright architecture?
7) What is OpenMax IL?
9) What are the call back functions in OpenMax IL?
10) What is ‘role of OMX_Component”?
11) How will you implement an OMX Component?
12) What is the use of OpenMax IL?
13) When “setparam” and “setconfig” functions will be used?
14) When “AllocateBuffer” and “Usebuffer” functions will be called?
15) What is the role of awesome player in Stage fright?
16) How will you integrate an s/w codec or hardware codec with stage fright?
17) How the player type is decided for playback of particular file format?
18) What is Meta data and how will it be extracted?
19) Will stage fright support all media file formats?
20) How the thumbnail image will be created?
21) What is role media scanner?
22) What is the role of media extractor?
23) What is the role of metadata retriever?
24) What is the functionality of Audio flinger?
25) What is the functionality of surface flinger?
26) What is the role of Audio policy Service and Audio Policy Manger?
27) Explain the State diagram of Phone state?
28) How Application Processor and Communication Processor will be communicated?
29) What are the native services that will start from media server?
30) How player app and media player service will be communicated?
31) What is Binder?
32) What are the IPC methods used in android?
33) How AV sync is managed during video playback?
34) How the buffer management will be done for playback and recording?
35) What is PMEM and ashmem?
36) What is audio track and audio sink in the context of playback?
37) What is mutex, and when it is used?
38) What is parser and renderer, will these be OMX Components?
39) How would you know whether s/w codec or h/w codec is used?
41) What is frame buffer?
42) What is egl swapbuffers?

43) What is parser? 
44) What is recogniser?
45) What is Payload?
46) Explain Power Saving Machanisam in Audio/Video Playback?
47) Explain Interrupts handling in Audio Playback?
48) Why up sampling and down sampling is required while routing different audio streams 
       data? 
49) Which is the flag we set when playback complete in OMX Component?
50) What a mp4 file header have in it? 51) What does Media Scanner do?
52) Where is thumbnail stored in a picture?
53) How AV sync is achieved in RTSP streaming?
54) In RTSP streaming, what RTCP Packets comprise of ?
55) What happens in JNI if many media player instances are created?
56) Who selects the codecs for encoding for Author Engine
57) What is the control path in RTP?
58) Which transport protocol is used in RTSP?
59) Which is preferred for streaming...? RTSP or HTTP?
60) Which is more preferred H263 or H264?
61) What is container and codec?
62) Can seek n pause operations be done in while streaming through rtsp?
63) What is interlaced and progressive streaming?
64) How do you synchronize between the audio and video streamed data?
65) Why RTSP is called real time?
66) Difference between HTTP n RTSP?
67) What is RTSP protocol?