Tuesday 13 January 2015

SQLite query returns a set of rows along with a pointer called  ?

cursor
A small message that is displayed to the user for a few seconds ?

Toast

A folder contains all of the source code of the application ?

src
component that responds to system-wide broadcast announcements ?

Broadcast Receiver
when background(AsyncTask) task completes ?

onPostExecute()

is an mechanism created to handle long operations that need to report UI thread ?

AsyncTask
is the callback specifies the work to be done on menu key press ?

onCreateOptionsMenu()
represents a single user interface screen ?

Activity
is used to uniquely identify the framework API revision offered by a version of the Android platform ?

Version Number
testing tests internal structures or workings of a program ?

White Box Testing

Monday 12 January 2015

What is cursor.moveToNext() ?

It will move the cursor to point to next row if it is available, else it returns false.
What is the purpose of the ContentProvider class ?

If you want to share the data of one application with the application then use content provider.  
Note: We can start an Activity, a service, and a broadcast receiver by using intents. 
But you can't start or communicate with a content provider by using intents. 
If you want to communicate with content provider then you have to use content resolver.  
1.content provider, and resolver will handle IPC(Inter process communication) mechanism when sharing data between 
2 applications. 2.content provider has the capability to handle multiple threads, when queries are coming from multiple resolvers.
When does onCreate() function of ContentProvider will be called ?

onCreate() will be called when the application containing the content provider is loaded into the memory for the first time.
Is it possible to have multiple actions in an intent-filter ?

intent-filters can have 0 - n number of actions, but if that component has only one intent-filter with 0 actions, then that component can be triggered using only explicit intents. a given intent-filter can have more than one action because, a given component can do more than one action. EG: notepad can perform two actions ACTION_VIEW & ACTION_EDIT on an existing note pad file.
what is the permission required to make a call in android, by using  ACTION_CALL ?

android.permission.CALL_PHONE

Sunday 11 January 2015

 How many types of menus are there in android ?

Options Menu - triggered when user presses menu hard key. This is deprecated starting from android 3.0. In place of options menu migrate to action bars.
Sub Menu - Menu with in a menu (only one level of sub menu is allowed).
Context Menu - Triggered when user press and hold on some view which was registered to show context menu.
What is the difference between menus and dialogs, in android ?

Menus are designed using xml, because menus will not change so frequently. You can build menus using code also when ever required. But it is not recommended to completely build menus using code.
Dialogs are built using code because dialog content will frequently change.
What is the life cycle of a started service ? 

oncreate 
onstartCommand() 
onDestroy()
What is the difference between service and intentservice in android  ? 

i  Intentservice by default will create one separate thread to handle the service functionality.
   All the startservice requests for intentservice will be routed to that thread. 
ii. Where as service by default runs in main thread. All the startservice requests will be routed to main thread by default. 
iii. While implementing a service, programmer has to implement onCreate(), onStartCommand(), and onDestroy() methods. 
iv. Where as while implementing IntentService programmer has to implement only onHandleIntent(). 
v. After starting IntentService, it will be automatically closed if there are no pending startService requests. 
vi. Where as for normal service programmer has to stop the service explicitly either by using stopSelf() or stopService() methods. 
vii. Don't try to touch UI from IntentService's onHandleIntent() method directly, as that function runs in a separate thread. (Not in main thread).

Thursday 8 January 2015

What is the difference between this context and getapplicationcontext ? 

There are two types of contexts available in android to create any component. 
1. this context (or) this pointer 
2. application context When programmer wants to create any component or control,
 then you have to use one of the contexts. 
 eg: TextView t = new TextView(this); Here we are using this pointer (context). 
 eg: static TextView st = new TextView(getApplicationContext()); 
 Here we are using application context, because it is a static variable whose life time will be through out application life time.

 If you use this pointer here, then it will leak memory (memory wastage) of your activity. 



  View.getContext()

  Returns the context the view is currently running in. Usually the currently active Activity.

  Activity.getApplicationContext()

  Returns the context for the entire application (the process all the Activities are running inside of.
  Use this instead of the current Activity context if you need a context  tied to the lifecycle of the entire 
  application, not just the current Activity. 

  ContextWrapper.getBaseContext()

  If you need access to a Context from within another context, 
  you use a ContextWrapper..
  The Context referred to from inside that ContextWrapper is accessed via  getBaseContext().

what is MODE_PRIVATE when creating shared preference file ?

only the process or application which has created that preference file can access it. other applications can't access it.
What is the difference between permission and uses-permission in android ?  

i. permission tag is used to enforce a user defined permission on a component of your application. 
ii. uses-permission tag is used to take a permission from the user for your application. 
iii. permission tag is used when you want other applications to seek permission from the user to use some of your applications components.
What is the root tag of a manifest file in android? (which will be immediately after xml tag).

manifest
What is the maximum memory limit given for each process or application in android ?

16 MB
What is android raw folder in eclipse project ?

it is used to store MP3 or other assets files
Android web browser is based on which source ?

Android web browser is based with free ware under Apache license that is web kit software.
What is APK in android, and What does .apk  file contains ?

APK - Application Package file. It is a file format used to distribute and install android applications. .apk will contain single .dex file, zipped resources, other non java library files (c/c++). .dex file will internally contains converted .class files. other wise .apk will not contains .class files.
What is R.java in android? What does it contain ?

It is automatic generated file, which have pointers to all resources used in the application.
Where all I can use Android ?

cars, watches, phones, tablets, laptops, robots, washing machines, traffic controllers, head phones, goggles, TVs.
What type of kernel is used in Android ?

Linux modified kernel (Monolithic) is used in Android
Android is released under which license ?

Android is freeware, it is under Apache license but only kernel layer is under GPL license.
Which company has released first android phone ?

In 2008 first android phone came from HTC.
which programming language should be used to create applications in Android ?

At the initial stages android application development was limited to use only Java. But later with NDK (Native Development Kit) programmers can use C & C++ to write applications. Recently there has been lot of support for lot of scripting languages as well.
What are the four essential states of an activity ?

  Active – if the activity is at the foreground
  Paused – if the activity is at the background and still visible
  Stopped – if the activity is not visible and therefore is hidden or obscured by another

  activity
  Destroyed – when the activity process is killed or completed terminated
Which component is not started by an intent ?

we use content resolver to start or communicate with content providers.

What are the permissions required to obtain phone locations ?

android.permission.ACCESS_FINE_LOCATION - use this if you are using GPS features in your programming. 
android.permission.ACCESS_COARSE_LOCATION - use this if you are fetching locations based on career network or by using WiFi.
In which library GeoCoder class is located  ?

GeoCoding is part of location's package. It is not related with Maps library.
What are the permissions required to access phone's location using NETWORK_PROVIDER ?

ACCESS_FINELOCATION
ACCESS_COARSE_LOCATION

NETWORK_PROVIDER will fetch locations either by using WiFi point or cell tower information. for cell tower we have to use COARSE_LOCATION permission and for WiFi we have to use FINELOCATION permission.

How to find whether GPS is disabled in the phone ?

if it is disabled onProviderDisabled() will be called with provider name.
How to get phone location? which is better network provider or GPS provider ?

You can either use your cell tower information or WiFi information to know your phone location.
How to create a SensorManager object to access and view list of sensors available in the phone ?

SensorManager s = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
What is the package name of HTTPClient ?

org.apache.http.client
What is the package name of JSONObject, JSONArray ?

org.json
To use HTTPClient, which permission is required in an android application ?

android.permission.INTERNET is mandatory for any HTTPRequest, as we are fetching or posting information using internet or by using network connection.

Wednesday 7 January 2015

If internet permission is not taken to use HTTP Client, then what will happen ?

With out internet permission, it will throw UnknownHostException which is part of IOException.
How To Send SMS Message In Android  ?

  SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra("sms_body", "Hii.....  i m Naveen Tamrakar an Android Developer from 
        Sehore(Bhopal)"); 
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);

<uses-permission android:name="android.permission.SEND_SMS" />
To use HTTPClient, which permission is required in an android application ?

android.permission.INTERNET is mandatory for any HTTPRequest, as we are fetching or posting information using internet or by using network connection.
What are the functionalities of HTTPClient interface in android ?

connection, authentication, Cookies management are the functionalities of HTTPClient interface
How to send mail in android  ?

        Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"er.naveen.tamrakar@gmail.com"}); intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "message");
intent.setType("message/rfc822");
        startActivity(Intent.createChooser(intent, "Choose an Email client :"));

How to use Hindi fonts in Android ?



 TextView t = new TextView(this);
 Typeface Hindi = Typeface.createFromAsset(getAssets(), "fonts/mangle.ttf");
 t.setTypeface(Hindi);
 t.setText("Naveen Tamrakar");


What items are important in every Android project ?

These are the essential items that are present each time an Android project is created:
- AndroidManifest.xml
- build.xml
- bin/
- src/
- res/
- assets/
What are Adapters and when and how are they used ?

It is tough to develop an Android app without using an adapter somewhere because they are so important.
 Where do adapters fit in? They bridge the Model and View (e.g. AdapterViews such as ListViews, GridViews, Spinners and ViewPagers) with underlying data. They provide access to data items and are responsible for creating a view for each item in the data set.
 Android doesn’t adopt the MVC pattern per se. You define the Model that works for you. Android helps you layout and render views, and you customize Android’s Activities and Fragments that typically act as Controllers.

 Novice developers might try to get away with using simple helper adapters like ArrayAdapter, SimpleAdapter and SimpleCursorAdapter when possible, but these are usually too limiting for some of the more complex views typically required by todays apps. Master developers will write adapters that extend BaseAdapter directly, because it is more powerful and flexible than the subclass helpers mentioned above.
What is an URI ?

Android uses URI strings both for requesting data (e.g., a list of contacts) and for requesting actions (e.g., opening a Web page in a browser). Both are valid URI strings, but have different values. All requests for data must start with the string “content://”. Action strings are valid URIs that can be handled appropriately by applications on the device; for example, a URI starting with “http://” will be handled by the browser.

Tuesday 6 January 2015

What is AsyncTask ?

AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread. An asynchronous task is defined by 3 generic types, called Params, Progress and Result, and 4 steps, called onPreExecute, doInBackground, onProgressUpdate and onPostExecute.
What are the different Storage Methods in android ?

Android provides many options for storage of persistent data. It provides the solution according to your need. The storages which have been provided in Android are as follows:

 Shared Preferences: Store private primitive data in key value pairs
 Internal Storage: Store private data on the device memory.
 External Storage: Store public data on the shared external storage.
 SQLite Databases: Store structured data in a private database.
 Network Connection: Store data on the web with your own network server.



What is a Sticky Intent ?

Intent is basically an abstract description of an operation that has to be performed for communication. Sticky Intent is also a type of intent which allows the communication between a function and a service.

 sendStickyBroadcast() performs a sendBroadcast (Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver (BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent). 
What is a Broadcast receivers ?

A broadcast receiver is a component that does nothing but receive and react to broadcast announcements.
 For example, announcements that the timezone has changed, that the battery is low or that the user changed a language preference.
 All receivers extend the BroadcastReceiver base class.

 Broadcast receivers do not display a user interface. However, they may start an activity in response to the information they receive, or they may use the NotificationManager to alert the user like(flashing the backlight, vibrating the device, playing a sound)
What is an Intent Filter ?

Activities and intent receivers include one or more filters in their manifest to describe what kinds of intents or messages they can handle or want to receive. An intent filter lists a set of requirements, such as data type, action requested, and URI format, that the Intent or message must fulfill. For Activities, Android searches for the Activity with the most closely matching valid match between the Intent and the activity filter. For messages, Android will forward a message to all receivers with matching intent filters.
What is the difference between Service and Thread ?

Service is like an Activity but has no interface. Probably if you want to fetch the weather for example you wolud not create a blank activity for it, for this you will use a Service. It is also known as Background Service because it performs tasks in background. 

A Thread is a concurrent unit of execution. You need to know that you cannot update UI from a Thread. You need to use a Handler for this.
What is a Toast Notification ? 

A toast notification is a message that pops up on the surface of the window. It only fills the amount of space required for the message and the users current activity remains visible and interactive. The notification automatically fades in and out, and does not accept interaction events.
What is Android Runtime ?

Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language. Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included dx tool.
What is Dalvik Virtual Machine ?

The name of Android virtual machine. The Dalvik VM is an interpreter-only virtual machine that executes files in the Dalvik Executable (.dex) format, a format that is optimized for efficient storage and memory-mappable execution. The virtual machine is register-based, and it can run classes compiled by a Java language compiler that have been transformed into its native format using the included dx tool. The VM runs on top of Posix-compliant operating systems, which it relies on for underlying functionality (such as threading and low level memory management). The Dalvik core class library is intended to provide a familiar development base for those used to programming with Java Standard Edition, but it is geared specifically to the needs of a small mobile device.
What is the difference between a file, a class and an activity in android ?

File: It is a block of arbitrary information, or resource for storing information. It can be of any type.

Class: Its a compiled form of .Java file . Android finally used this .class files to produce an executable apk.

Activity: An activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type it is just a class that can be extended in Android for loading UI elements on view.
Describe the APK format ?

The (Android Packaging Key) APK file is compressed format of the AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.


Where can you define the icon for your Activity ?

<activity android:icon="@drawable/app_icon" android:name=".MyTestActivity"></activity>
Where will you declare your activity so the system can access it ?

Activity is to be declared in the manifest file. For example:

  <activity android:name=".MyTestActivity"></activity>
How will you pass data to sub-activities ?

We can use Bundles to pass data to sub-activities. There are like HashMaps that and take trivial data types. These Bundles transport information from one Activity to another.


        ...
        Bundle b = new Bundle();
        b.putString("EMAIL", "abc@xyz.com");
        i.putExtras(b); // where i is the intent

        ...
What is an Action ?

Action in Android glossary is something that an Intent sender wants done. It is a string value that is assigned to intent. Action string can be defined by the Android itself or by you as third party application developer.
Name the resource that is a compiled visual resource and can be used as a background, title, or in other part of the screen ?

 Drawable is the virtual resource that can e used as a background, title, or in other parts of the screen. It is compiled into an android.graphics.drawable subclass.
How will you call a subactivity ?

       
      Intent intent = new Intent(this, SubActivity.class);
          addintent.putExtra(name, value);

          startActivityForResult(intent, int);
Write code snippet to retrieve IMEI number of Android phone ?

TelephonyManager class can be used to get the IMEI number. It provides access to information about the telephony services on the device.

       TelephonyManager mTelephonyMgr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

        String imei = mTelephonyMgr.getDeviceId();
What attribute values should be localized ?

The attribute values that can be displayed to users should be localized. For example: label, icon etc.
How can your application perform actions that are provided by other application e.g. sending email ?

Intents are created to define an action that we want to perform and the launches the appropriate activity from another application.

        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.putExtra(Intent.EXTRA_EMAIL, recipientArray);
        startActivity(intent);
 How will you launch an Activity within you application ?

For launching an application, we will need to create an intent that explicitly defines the activity that we wish to start. For example:

       Intent intent = new (this,MyActivity.class);
       startActivity(intent);


An Android application needs to access device data e.g SMS messages, camera etc. At what stage user needs to grant the permissions ?

Application permission must be granted by the user at install time.
Can an Android application access files or resources of another Android application ?

The system sets permission on all the files/resources of an application so that they are only accessible by their own application. Other applications cannot access resources belonging to other applications unless applications sign the same certificate.
 Define Activity application component ?

It is used to provide interactive screen to the users. It can contain many user interface components. A typical Android application consists of multiple activities that are loosely bound to each other. Android developer has to define a main activity that is launched on the application startup.

Which dialog boxes can you use in you Android application ?


 AlertDialog: it supports 0 to 3 buttons with a list of selectable elements that includes check  boxes and radio  buttons.
 ProgressDialog: it displays the progress of any dialog or application. It is an extension of  AlertDialog and  supports adding buttons.
 DatePickerDialog: it is used to give provision to the user to select the date.
 TimePickerDialog: it is used to give provision to the user to select the time.

Define Android application resource files ?

As an Android application developer, you can inject files (XML, JSON, JPEG etc) into the build process and can load them from the code. These injected files are revered as resources.
What needs to be done in order to set Android development environment where Eclipse IDE is to be used ?

Download the Android SDK from Android homepage and set the SDK in the preferences. Windows > Preferences > Select Android and enter the installation path of the Android SDK. Alternatively you may use Eclipse update manager to install all available plugins for the Android Development Tools (ADT).
Is it okay to change the name of an application after its deployment ?

It is not recommended to change the application name after its deployment because this action may break some functionality. For example: shortcuts will not work if you change application name.
How can two Android applications share same Linux user ID and share same VM ?

The applications must sign with the same certificate in order to share same Linux user ID and share same VM.
When does Android start and end an application process ?

Android starts an application process when application's component needs to be executed. It then closes the process when it's no longer needed (garbage collection).
How does an application run in isolation from other applications ?

Each application gets its own Linux user ID and virtual machine which means that the application code runs in isolation from other applications.
How does Android system track the applications ? 

Android system assigns each application a unique ID that is called Linux user ID. This ID is used to track each application.
What are Dalvik Executable files ?

Dalvik Executable files have .dex extension and are zipped into a single .apk file on the device.
Android application can only be programmed in Java ?

False. You can program Android apps in C/C++ using NDK .
Can you deploy executable JARs on Android? Which packaging is supported by Android ?

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.

Why cannot you run standard Java byte code on Android ?

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.

Monday 5 January 2015

What is ANR ?

ANR stands for Application Not Responding. It is a dialog box that appears if the application is no longer responding.

What is NDK ?

NDK stands for Native Development Kit. By using NDK, you can develop a part of app using native language such as C/C++ to boost the performance.

What is ADB ?

ADB stands for Android Debug Bridge. It is a command line tool that is used to communicate with the emulator instance.

What is fragment ?

Fragment is a part of Activity. By the help of fragments, we can display multiple screens on one activity.

What is content provider ?


Content Providers are the only way to share data across Android applications. They store and retrieve data thus making it accessible to all. Content Providers give a uniform interface to access the data. Android platform provides default implementations of content providers for data types like audio, video, images, contact information etc.

What is AAPT ?


AAPT is short for Android Asset Packaging Tool. This tool provides developers with the ability to deal with zip-compatible archives, which includes creating, extracting as well as viewing its contents.

What is service in android ?


A Service is an application component representing either an applications desire to perform a longer running operation while not interacting with the user or to supply functionality for other applications to use. Services run without a dedicated GUI, but, like Activities and Broadcast Receivers, they still execute in the main thread of the applications process. A Service could be, facility for an application to expose some of its functionality to other applications.

How to call another activity in android ?


 Intent i = new Intent(getApplicationContext(), Activity_Two.class); 

 startActivity(i);  

What is explicit intent in android ?


Explicit intent is used to invoke the activity class.

In an explicit intent, we actually specify the activity that is required to respond to the intent. In other words, we explicitly designate the target component. This is typically used for application internal messages.

 Intent intent = newIntent (this, SecondActivity.class);

 startActivity(intent);

What is implicit intent in android ?


Implicit intent is used to invoke the system components.

In an implicit intent, the main power of the android design, we just declare an intent and leave it to the platform to find an activity that can respond to the intent. Here, we do not declare the target component and hence is typically used for activating components of other applications seamlessly.

 If you want to view a web page with the specified URL then you can use this procedure.
 Intent i = newIntent(android.content.Intent.ACTION_VIEW,Uri.parse(“http://www.amazon.com”));

 startActivity(i);

What is intent ?


It is a kind of message or information that is passed to the components. It is used to launch an activity, display a web page, send sms, send email etc. There are two types of intents in android:
  1. Implicit Intent
  2. Explicit Intent

What are the life cycle methods of android Activity ?


  As an activity transitions from state to state, it is notified of the change by calls to the  
  following protected methods:

  1.     void onCreate(Bundle savedInstanceState)
  2.     void onStart()
  3.     void onRestart()
  4.     void onResume()
  5.     void onPause()
  6.     void onStop()
  7.     void onDestroy()
 
 Taken together, these seven methods define the entire lifecycle of an activity.




What is activity ?


Activity is like a frame or window in java that represents GUI. It represents one screen of android.

An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.




What are the core building blocks of android ?


The core building blocks of android are:
  • Activity - single screen on android mobile
  • View
  • Fragment 
  • Services – like Network Operation 
  •  Intent - To perform inter-communication between activities or services.
  •  Resource Externalization - such as strings and graphics.
  •  Notification signaling users - light, sound, icon, notification, dialog etc.
  •  Content Providers - They share data between applications
  •  How will you record a phone call in Android? How to get a handle on Audio Stream for a call in Android?
  •  Permissions.PROCESS_OUTGOING_CALLS: Allows an application to monitor, modify, or abort outgoing calls.

Does android support other language than java ?


Yes, android app can be developed in C/C++ also using android NDK (Native Development Kit).  
It makes the performance faster. It should be used with android SDK.

What are the advantages of android ?


Open-source: It means no licence, distribution and development fee.

Platform-independent: It supports windows, mac and linux platforms.

Supports various technologies: It supports camera, bluetooth, wifi, speech, EDGE etc. technologies.

Highly optimized Virtual Machine: Android uses highly optimized virtual machine for mobile devices, called DVM (Dalvik Virtual Machine).

 It is simple and powerful SDK.
 Licensing, Distribution or Development fee is not required.
 Easy to Import third party Java library.
 Supporting platforms are – Linux, Mac Os, Windows.
 Innovative products like the location-aware services, location of a nearby convenience store  etc., are some of  the additive facilities in Android. Components can be reused and replaced by  the application framework. 
 Optimized DVM for mobile devices.
 SQLite enables to store the data in a structured manner.
 Supports GSM telephone and Bluetooth, WiFi, 3G and EDGE technologies.
 The development is a combination of a device emulator, debugging tools, memory profiling and  plug-in for  Eclipse IDE.
 The customer will be benefited from wide range of mobile applications to choose.