`
chriszeng87
  • 浏览: 741182 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

android interview questions

阅读更多
Android interview questions - posted on April 23, 2014 at 15:29 PM by Raj Singh 

Q.1 Explain in brief about the important file and folder when you create new android application.

When you create android application the following folders are created in the package explorer in eclipse which are as follows:

src: Contains the .java source files for your project. You write the code for your application in this file. This file is available under the package name for your project.

gen —This folder contains the R.java file. It is compiler-generated file that references all the resources found in your project. You should not modify this file.

Android 4.0 library: This folder contains android.jar file, which contains all the class libraries needed for an Android application.

assets: This folder contains all the information about HTML file, text files, databases, etc.

bin: It contains the .apk file (Android Package) that is generated by the ADT during the build process. An .apk file is the application binary file. It contains everything needed to run an Android application.

res: This folder contains all the resource file that is used byandroid application. It contains subfolders as: drawable, menu, layout, and values etc.

Explain AndroidManifest.xmlfile in detail.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.careerride" android:versionCode="1" android:versionName="1.0">

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" />

<application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">

<activity android:name="com.example.careerride.MainActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>

The AndroidManifest.xml file contains the following information about the application:

  • It contains the package name of the application.
  • The version code of the application is 1.This value is used to identify the version number of your application.
  • The version name of the application is 1.0
  • The android:minSdkVersion attribute of the element defines the minimum version of the OS on which the application will run.
  • ic_launcher.png is the default image that located in the drawable folders.
  • app_name defines the name of applicationand available in the strings.xml file.
  • It also contains the information about the activity. Its name is same as the application name.

Describe android Activities in brief.

Activity provides the user interface. When you create an android application in eclipse through the wizard it asks you the name of the activity. Default name is MainActivity. You can provide any name according to the need. Basically it is a class (MainActivity) that is inherited automatically from Activity class. Mostly, applications have oneor more activities; and the main purpose of an activity is to interact with the user. Activity goes through a numberof stages, known as an activity’s life cycle.

Example:

packagecom.example.careerride; //Application name careerride

importandroid.os.Bundle; // Default packages
importandroid.app.Activity; // Default packages
importandroid.view.Menu;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
publicbooleanonCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;

}

When you run the application onCreate method is called automatically.

Describe Intents in detail.

An Android application can contain zero or more activities. If you want to navigate fromone activity to another then android provides you Intent class. This class is available inandroid.content.Intent package.One of the most common uses for Intents is to start new activities.

There are two types of Intents.

Explicit Intents
Implicit Intents

Intents works in pairs: actionand data. The action defines what you want to do, such as editing an item, viewingthe content of an item etc. The dataspecifies what is affected,such as a person in the Contacts database. The data is specified as anUri object.

Explicitly starting an Activity

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

startActivity(intent);

Here SecondActivity is the name of the target activity that you want to start.

Implicitly starting an Activity

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);

if you want to dial a telephone number then you can use this method by passing the telephone number in the data portion

Intent i = newIntent (android.content.Intent.ACTION_DIAL,Uri.parse(“tel:+9923.....”));

startActivity(i);

In the above method the user must press the dial button to dial the number. If you want to directly call the number without user intervention, change the action as follows:

Intent i = newIntent (android.content.Intent.ACTION_CALL,Uri.parse(“tel:+9923.....”));

startActivity(i);

If you want to dial tel no or use internet then write these line in AndroidManifest.xml

<uses-permissionandroid:name=”android.permission.CALL_PHONE”/>
<uses-permissionandroid:name=”android.permission.INTERNET”/>

How to send SMS in android? Explain with example.

SMS messaging is one of the basic and important applications on a mobile phone. Now days every mobile phone has SMS messaging capabilities, and nearly all users of any age know how to send and receive suchmessages. Mobile phones come with a built-in SMS application that enables you to send and receiveSMS messages. If you want to send the SMS programmatically then follow the following steps.

Sending SMS Messages Programmatically

Take a button on activity_main.xml file as follows.

<Button android:id="@+id/btnSendSMS" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:onClick=”sendmySMS” android:text="sendSMS" />

According to above code when user clicks the button sendmySMS method will be called. sendmySMS is user defined method.

In the AndroidManifest.xml file, add the following statements

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

Now we write the final step. Write the given below method in MainActivity,java file

publicvoidsendmySMS(View v)
{
SmsManagersms = SmsManager.getDefault(); 
sms.sendTextMessage("5556", null, "Hello from careerRide", null, null);
}
In this example I have used two emulator. On the first Android emulator (5554), click the Send SMSbutton to send an SMS message to the second emulator(5556).

Describe the SmsManager class in android.

SmsManager class is responsible for sending SMS from one emulator to another or device.

You cannot directly instantiate this class; instead, you call the getDefault() static method to obtain an SmsManager object. You then send the SMS message using the sendTextMessage() method:

SmsManagersms = SmsManager.getDefault();

sms.sendTextMessage("5556", null, "Hello from careerRide", null, null);

sendTextMessage() method takes five argument.

  • destinationAddress — Phone number of the recipient.
  • scAddress — Service center address; you can use null also.
  • text — Content of the SMS message that you want to send.
  • sentIntent — Pending intent to invoke when the message is sent.
  • deliveryIntent — Pending intent to invoke when the message has been delivered.

How you can use built-in Messaging within your application?

You can use an Intent object to activate the built-in Messaging service. You have to pass MIME type “vnd.android-dir/mms-sms”, in setType method of Intent as shown in the following given below code.

Intent intent = new Intent (android.content.Intent.ACTION_VIEW);
intent.putExtra("address", "5556; 5558;");// Send the message to multiple recipient.
itent.putExtra("sms_body", "Hello my friends!"); 
intent.setType("vnd.android-dir/mms-sms");
startActivity(intent);

What are different data storage options are available in Android?

Different data storage options are available in Android are:

  • SharedPreferences
  • SQlite
  • ContentProvider
  • File Storage
  • Cloud Storage

Describe SharedPreference storage option with example.

SharedPreference is the simplest mechanism to store the data in android. You do not worry about creating the file or using files API.It stores the data in XML files. SharedPreference stores the data in key value pair.The SharedPreferences class allows you to save and retrieve key-value pairs of primitive data types. You can use SharedPreferences to save any primitive data: boolean, floats, int, longs, and strings.The data is stored in XML file in the directory data/data//shared-prefs folder.

Application of SharedPreference

  • Storing the information about number of visitors (counter).
  • Storing the date and time (when your Application is updated).
  • Storing the username and password.
  • Storing the user settings.

Example:

For storing the data we will write the following code in main activity on save button:

SharedPreferences sf=getSharedPreferences("MyData", MODE_PRIVATE);
SharedPreferences.Editored= sf.edit(); 
ed.putString("name", txtusername.getText().toString()); 
ed.putString("pass", txtpassword.getText().toString()); 
ed.commit();

In this example I have taken two activities. The first is MainActivity and the second one is SecondActivity.When user click on save button the user name and password that you have entered in textboxes, will be stored in MyData.xml file.

Here MyData is the name of XML file .It will be created automatically for you. 

MODE_PRIVATE means this file is used by your application only.

txtusernameand txtpassword are two EditText control in MainActivity.

For retrieving the data we will write the following code in SecondActiviy when user click on Load button:

Public static final String DEFAULT=”N? A”;

DEFAULT is a String type user defined global variable.If the data is not saved in XML file and user click on load button then your application will not give the error. It will show message “No Data is found”. Here name and pass are same variable that I have used in MainActivity.

SharedPreferences sf=getSharedPreferences("MyData", Context.MODE_PRIVATE);

String Uname=sf.getString("name", DEFAULT);

String UPass=sf.getString("pass", DEFAULT);

if(name.equals(DEFAULT)||Pass.equals(DEFAULT)) 
{
Toast.makeText(this, "No data is found", Toast.LENGTH_LONG).show(); 
}

else

{

Txtusername.setText(Uname);
Txtpassword.setText(UPass) ;
}

Android test   iPhone   Android   Blackberry   iPOD  iTouch

Android interview online test (100 questions)  -By Pradip Patil, Lecturer IIMP MCA

Android interview questions - posted on June 27, 2013 at 15:29 PM by Kshipra Singh 

1. What are the key components of Android Architecture?

Android Architecture consists of 4 key components:
- Linux Kernel
- Libraries
- Android Framework
- Android Applications

2. What are the advantages of having an emulator within the Android environment?

- The emulator allows the developers to work around an interface which acts as if it were an actual mobile device.
- They can write, test and debug the code.
- They are safe for testing the code in early design phase

3. Tell us something about activityCreator?

- An activityCreator is the initial step for creation of a new Android project.
- It consists of a shell script that is used to create new file system structure required for writing codes in Android IDE.

4. What do you know about Intents?

- Notification messages to the user from an Android enabled device can be displayed using Intents. The users can respond to intents. 
- There are two types of Intents - Explicit Intent, Implicit Intent.

5. What is an Explicit Intent?

- Explicit intent specifies the particular activity that should respond to the intent. 
- They are used for application internal messages.

6. What is an Implicit Intent?

- In case of Implicit Intent, an intent is just declared. 
- It is for the platform to find an activity that can respond to it.
- Since the target component is not declared, it is used for activating components of other applications.

7. What do intent filters do?

- There can be more than one intents, depending on the services and activities that are going to use them. 
- Each component needs to tell which intents they want to respond to. 
- Intent filters filter out the intents that these components are willing to respond to.

8. Where are lay out details placed? Why?

- Layout details are placed in XML files
- XML-based layouts provide a consistent and standard means of setting GUI definition format.

9. What do containers hold?

- Containers hold objects and widgets in a specified arrangement. 
- They can also hold labels, fields, buttons, or child containers. .

10. What is Orientation?

- Orientation decides if the LinearLayout should be presented in row wise or column wise fashion. 
- The values are set using setOrientation()
- The values can be HORIZONTAL or VERTICAL

11. What is it important to set permissions in app development?

- Certain restrictions to protect data and code can be set using permissions. 
- In absence of these permissions, codes could get compromised causing defects in functionality.

12. What is AIDL?

- AIDL is the abbreviation for Android Interface Definition Language. 
- It handles the interface requirements between a client and a service to communicate at the same level through interprocess communication. 
- The process involves breaking down objects into primitives that are Android understandable.

13. What data types are supported by AIDL?

AIDL supports following data types:
-string
-List
-Map
-charSequence
and
-all native Java data types like int,long, char and Boolean

14. Tell us something about nine-patch image.

- The Nine-patch in the image name refers to the way the image can be resized: 4 corners that are unscaled, 4 edges that are scaled in 1 axis, and the middle one that can be scaled into both axes.
- A Nine-patch image allows resizing that can be used as background or other image size requirements for the target device.

15. Which dialog boxes are supported by android?

Android supports 4 dialog boxes:

a.) AlertDialog: Alert dialog box supports 0 to 3 buttons and a list of selectable elements which includes check boxes and radio buttons. 

b.) ProgressDialog: This dialog box is an extension of AlertDialog and supports adding buttons. It displays a progress wheel or bar.

c.) DatePickerDialog: The user can select the date using this dialog box. 

d.) TimePickerDialog: The user can select the time using this dialog box.

16. What is Dalvik Virtual Machine?

- It is Android's virtual machine. 
- It is an interpreter-only virtual machine which executes files in Dalvik Executable (.dex) format. This format is optimized for efficient storage and memory-mappable execution.

1.What is android? What are the features of Android?

Android is a stack of software for mobile devices which has Operating System, middleware and some key applications..............
Read answer

2.Why to use Android?

Android is useful because: 1) It is simple and powerful SDK.............
Read answer

3.Describe Android Application Architecture.

Android Application Architecture has the following components:...........
Read answer

4.Describe a real time scenario where android can be used

Imagine a situation that you are in a country where no one understands the language you speak and you can not read or write.............
Read answer

5.What are the advantages of Android?

The following are the advantages of Android: 1) The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like AT&T and Orange will be broken by Google Android.................
Read answer

6.How to select more than one option from list in android xml file? Give an example.

Specify android id, layout height and width as depicted in the following example............
Read answer

7.What is needed to make a multiple choice list with a custom view for each row?

Multiple choice list can be viewed by making the CheckBox android:id value be “@android:id /text1"...........
Read answer

8.What are the dialog boxes that are supported in android? Explain.

Android supports 4 dialog boxes: AlertDialog : An alert dialog box supports 0 to 3 buttons and a list of selectable elements, including check boxes and radio buttons............
Read answer

9.Explain about the exceptions of Android.

The following are the exceptions that are supported by Android............
Read answer

10.What is the TTL (Time to Live)? Why is it required?

TTL is a value in data packet of Internet Protocol. It communicates to the network router whether or not the packet should be in the network for too long or discarded.................

11.What are the differences between a domain and a workgroup?

In a domain, one or more computer can be a server to manage the network. On the other hand in a workgroup all computers are peers having no control on each other.............

12.Explain IP datagram, Fragmentation and MTU.

 

IP datagram can be used to describe a portion of IP data. Each IP datagram has set of fields arranged in an order. The order is specific which helps to decode and read the stream easily...............

 

转自:http://careerride.com/android-interview-questions.aspx

分享到:
评论

相关推荐

    Android代码-Android Interview Questions

    Android Interview Questions &gt; Android Interview Questions - Your Cheat Sheet For Android Interview We will be adding answers to the more questions on our MindOrks website. Prepared and maintained ...

    Android Interview Questions.zip

    这份"Android Interview Questions.zip"压缩包文件包含了关于Android开发的面试问题集锦,是开发者准备面试的绝佳参考资料。以下是基于这个压缩包文件名和描述的一些核心Android知识点的详细说明: 1. **Android...

    Android Interview Questions & Answers

    ### Android面试问题与解答:面向对象编程概念详解 在Android开发乃至整个软件工程领域中,面向对象编程(Object-Oriented Programming, OOP)是一种核心的设计思想和技术手段。本文将详细解析面向对象编程中的四大...

    Android代码-AndroidInterview-Q-A

    The top Internet companies android interview questions and answers Github Repo welcome star | Github 仓库 欢迎star 中文版Gitbook English Doc English version gitbook is coming soon..

    Android-Android-Interview-Questions.zip

    Android-Android-Interview-Questions.zip,收集Android和Java相关的问题和主题,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全性优势。

    android-interview-questions.zip

    "android-interview-questions.zip"这个压缩包很可能包含了关于Android面试常见问题的集合,旨在帮助求职者准备面试。"android-interview-questions-master"可能是一个代码仓库或者文档目录,包含了各种Android面试...

    android-interview-questions,你的安卓面试备忘单-安卓面试问题.zip

    "android-interview-questions,你的安卓面试备忘单-安卓面试问题.zip" 是一个开源项目,旨在为准备安卓面试的开发者提供一个全面的问题集合。这个压缩包中的"android-interview-questions-master" 文件可能包含了...

    Android代码-interview

    Please visit my wiki link for full list of questions https://github.com/mission-peace/interview/wiki Like my facebook page for latest updates on my youtube channel ... Contribution ...

    Android1面试题

    ### Android Interview Questions: AIDL详解 #### 一、AIDL简介与作用 ##### 1. 什么是AIDL? AIDL,全称为Android Interface Definition Language,是Android系统内部用于定义接口的语言,它允许不同进程间通过...

    Android代码-Q.careercup

    A mobile app to enjoy interview questions from popular websites like: ⦙ leetcode.com ⦙ lintcode.com ⦙ careercup.com ⦙ :bulb: Inspired by leetcode-cli, and careercup-cli. A tool to utilize your ...

    国内面试leetcode-Android-Interview:Android-面试

    Awesome-Android-Interview 收集了国内一二线互联网公司最常用的面试题。 它非常全面。 我花了很多精力和时间,我希望得到大家的。 支持。 Android面试经常涉及的问题如下: 1、计算机基础:TCP/IP、HTTP/HTTPS、...

    android-interview-questions:您的Android面试备忘单-Android面试问题

    Android面试题 Android面试问题-Android面试秘籍由编写和维护, 具有接受许多Android开发人员的采访以及对顶级公司的采访的经验。学习Android开发的完整指南-内容核心Android基础告诉所有Android应用程序组件。 - ...

    Java-Interview-Questions-and-Answers

    ### Java Interview Questions and Answers #### 1. 什么是 Java?解释其含义与定义。 Java 是当今最流行的编程语言之一,在 Web 应用程序、移动应用、软件开发、游戏系统以及服务器端技术等领域扮演着重要角色。...

    Awesome-Android-Interview:很棒的android专家访谈问答(持续更新中……)

    "Awesome-Android-Interview"项目就是一个针对Android面试的宝贵资源,它汇集了众多专家的面试问答,帮助开发者准备面试,提升专业能力。 一、Java基础 Java是Android开发的基础,理解其核心概念至关重要。这包括但...

    Java收银机源码-android-interview-questions-by-firoz:这里收集了印度不同公司针对经验丰富的Androi

    Java收银机源码android-java-interview-questions-by-firoz 这里收集了在印度不同公司提出的所有面试问题,供新手到有经验的 android 开发人员使用。 问:什么是安卓? Android 是一种基于 Linux 的开源操作系统,可...

    InterviewQuestions

    总之,"InterviewQuestions"涵盖了Android开发中的关键概念,包括UI组件的使用(ListFragment)和用户体验优化(后台数据加载)。在准备面试时,深入理解和掌握这些知识点将有助于展示你的专业技能,提高面试成功的...

    android-interview-questions:根据我的经验在DS,Java和Android上包含面试问题的资料库

    Android面试问题根据我的经验,包含有关DS,Java和Android的面试问题的资料库。注意:我现在不在这里写下答案,因为如果我为您提供答案,您会怎么做? :-)同样,您将只限于那些答案。尝试并深入了解这些概念。对于...

    Android-Interview-Questions:我在许多访谈中都遇到的与Android和Java有关的所有问题的集合

    Android面试问题在过去的几个月中,我接受了许多公司的采访,收集了问题并在此处列出,并将继续进行更新。 目前,我仅更新问题,很快我将更新答案。 什么是合子过程。 什么是Dagger,并解释依赖注入。 什么是改造...

    java字符串和数组笔试题-Android-Interview-Questions:安卓面试题

    Android 开发人员职位的技术面试问题,这些问题是我或我通常从其他候选人那里问到的。 随意贡献和改进它。 目录 一般的问题 你最近的 3 个申请是什么? 哪个是最好的? 为什么? 你最喜欢的编程语言是什么? - 为...

    JAVA单例模式源码-android-interview-questions:Android面试题和答案。这个repo适合面试官,被面试者,以

    android 问题和基础知识的了解。 重要提示:没有必要知道和阅读后面会提到的所有问题。 根据公司的领域、规模、产品和要求,选择并阅读相应的问题。 目录 1. 面向对象 什么是对象? 对象是具有状态和行为的类的实例...

Global site tag (gtag.js) - Google Analytics