Tuesday 23 July 2013

Android Interview Questions and Answers

Today(23 July 2013) i attended android interview and following were the questions. 

1. What is android?

      ans: Android is a stack of software for mobile devices which has Operating System, middleware and some key applications. The application executes within its own process and its own instance of Dalvik Virtual Machine.Many Virtual Machines run efficiently by a DVM device. DVM executes Java language byte code which later transforms into .dex format files.

2. Explain about the exceptions of Android?

     ans: The following are the exceptions that are supported by Android
            i. InflateException : When an error conditions are occurred, this exception is thrown
            ii. Surface.OutOfResourceException: When a surface is not created or resized, this exception is thrown
            iii. SurfaceHolder.BadSurfaceTypeException: This exception is thrown from the lockCanvas() method, when invoked on a Surface whose is SURFACE_TYPE_PUSH_BUFFERS
            iv. WindowManager.BadTokenException: This exception is thrown at the time of trying to add view an invalid WindowManager.LayoutParamstoken.

3. Describe the APK format.

        ans: The APK file is compressed the AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.

4. What is .dex extension?

     ans: Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single.apk file on the device. .dex files can be created by automatically translating compiled applications written in the Java programming language.

5. Explain the Architecture of Android ?

     ans: Android Architecture is made up of 4 key components:
            - Linux Kernel            
            - Libraries
            - Android Framework
            - Android Applications

6. what is services ?

      ans:  services is a background process it can't provide any user interaction screen . service run an long time process. even the application is switched but service can run.

7. what is an indent ?


      ans: indents are asynchronous messages, running around the inside of the device, notifying applications of various events. communication between the three core components in android activity ,services and broadcast receiver in made possible using indents .         

8. what is Broadcast Receiver ?

       ans: BroadcastReceiver can be registered to receive system messages and Intents. A BroadcastReceiver will get notified by the Android system, if the specified situation happens. For example a BroadcastReceiver could get called once the Android system completed the boot process or if a phone call is received.

9. What is an activity?

       ans: A single screen in an application, with supporting Java code. An activity presents a visual user interface for one focused endeavor the user can undertake. For example, an activity might present a list of menu items users can choose from or it might display photographs along with their captions.

10. What is an DDMS ?

       ans: Dalvik Debug Monitor Service, a GUI debugging application shipped with the SDK. It provides screen capture, log dump, and process examination capabilities.


11. What dialog boxes are supported in android?
       
        ans: Android supports 4 dialog boxes:
                1. Alert dialog
                2. Progress dialog
                3.Date picker dialog 
                4. Time picker dialog

12.  How the nine-patch Image different from a regular bitmap? 

       ans: A.It is one of a resizable bitmap resource which is being used as backgrounds or other images on the device. The NinePatch class allows drawing a bitmap in nine sections. The four corners are unscaled; the middle of the image is scaled in both axes, the four edges are scaled into one axis.

13. What is a resource?
     
        ans: user defined JSON, XML, bitmap, or other file, injected into the application build process, which can later be loaded from code.

14. How will you record a phone call in Android? 

      ans: Permission.PROCESS_OUTGOING_CALLS: Will Allow an application to monitor, modify, or abort outgoing calls. So using that permission we can monitor the Phone calls.

15. Does Android support the Bluetooth serial port profile?
     
        ans: Yes.

16. Can an application be started on powerup?
      
       ans: Yes.

17, How many ways data stored in Android?
         
        ans:  Android supports 5 way to store data:
                 1.SharedPreferences
                 2.Internal Storage
                 3.External Storage
                 4.SQLite Database
                 5.Network connection

18. Types of Android applications?
        ans: 1.Foreground
                2.Background
                3.Intermittent
                4.Widget

19. Why cannot you run standard Java bytecode on Android?

        ans: Android uses Dalvik Virtual Machine (DVM) which requires a special bytecode. We need to convert Java class files into Dalvik Executable files using an Android tool called "dx". In normal circumstances, developers will not be using this tool directly and build tools will care for the generation of DVM compatible files.

20. Can you deploy executable JARs on Android? Which packaging is supported by Android?

    ans:  No. Android platform does not support JAR deployments. Applications are packed into Android Package (.apk) using Android Asset Packaging Tool (aapt) and then deployed on to Android platform. Google provides Android Development Tools for Eclipse that can be used to generate Android Package.

21. Android application can only be programmed in Java?
  
     ans:  False. You can program Android apps in C/C++ using NDK .


Tuesday 12 February 2013

Use an intent filter to open app from weblink



      This is a simple piece of code that helps user to open an application installed in the device by matching the web app website link that is entered to the browser.

      To elaborate the usability.  Once the I enter the link into the browser he is pop upped with an alternate option to open the app installed in device or to navigate tot the application website link



Code is here :



1:        <intent-filter>  
2:          <category android:name="android.intent.category.DEFAULT" />  
3:          <category android:name="android.intent.category.BROWSABLE" />  
4:          <data android:host="trkalimuthu.com" android:scheme="http" />  
5:          <data android:host="www.trkalimuthu.com" android:scheme="https" />  
6:          <action android:name="android.intent.action.VIEW" />  
7:        </intent-filter>  





next pice of code is used webapp to lunch android app.


add this code in android mainfest file :
1:  <intent-filter>  
2:      <action android:name="com.trkalimuthu.android.MY_ACTION" />  
3:      <category android:name="android.intent.category.DEFAULT" />  
4:      <category android:name="android.intent.category.BROWSABLE" />  
5:  </intent-filter>  


following code will apper in webapp :

1:   <a href="intent:#Intent;action=com.trkalimuthu.android.MY_ACTION;end">Lunch App</a>  





the following code is used for lancu the webapp via application 

1:   startActivity(new Intent(Intent.ACTION_VIEW,  
2:                 Uri.parse("http://commonsware.com/sample")));  







Monday 4 February 2013

Android Building Blocks

Android Terminology

        Mobile devices have limited resources to understand application so android they flow some terminological thus app building blocks.           

  • Activity 
  • Content 
  • Indent 
  • Services 
  • Broadcast Receiver

What is an Activities :  

           The Android application each screen called activity. in an application contain more then one activity. 

what is content :

           content is an abstract class . it contains many methods. what subclass need . the
 content contains a top level application details.
            we can get other application files and db dates using  content class .  mostly content contains Activity and Service.
            use the content to share your data to other application.


what is services :

             services is a background process it can't provide any user interaction screen .
             service run an long time process. even the application is switched but service can run.. 


what is an indent : 

            indents are asynchronous messages, running around the inside of the device, notifying applications of various events. communication between the three core components in android activity ,services and broadcast receiver in made possible using indents .         

what is Broadcast Receiver :  

            BroadcastReceiver can be registered to receive system messages and Intents. A BroadcastReceiver will get notified by the Android system, if the specified situation happens. For example a BroadcastReceiver could get called once the Android system completed the boot process or if a phone call is received.