Вы находитесь на странице: 1из 17

What is android and sdk features:-

Android is a Linux based operating system it is designed primarily for touch screen mobile devices such as
smart phones and tablet computers. The operating system has developed a lot in last 15 years starting from
black and white phones to recent smart phones or mini computers. One of the most widely used mobile OS  
these days is android.  The android is software that was founded in Palo Alto of California in 2003.

The android is a powerful operating system and it supports large number of applications in Smartphone’s.
These applications are more comfortable and advanced for the users. The hardware that supports android
software is based on ARM architecture platform. The android is an open source operating system means that
it’s free and any one can use it. The android has got millions of apps available that can help you managing your
life one or other way and it is available low cost in market at that reasons android is very popular.

4 major features for the new Android SDK


Messaging
SMS and MMS are available forms of messaging, including threaded text messaging and Android Cloud To Device Messaging
(C2DM) and now enhanced version of C2DM, Android Google Cloud Messaging (GCM) is also a part of Android Push Messaging
services. Android phones also have the ability to send and receive RCS via the messages app (if supported by the carrier).
Web browser
The web browser available in Android is based on the open-source Blink (previously Web Kit) layout engine, coupled
with Chromium's V8 JavaScript engine. Then the Web Kit-using Android Browser scored 100/100 on the Acid3 test on Android
4.0 ICS; the Blink-based browser currently has better standards support. The old web browser is variably known as 'Android
Browser', 'AOSP browser', 'stock browser', 'native browser', and 'default browser' (from the time it was always the default).
Starting with Android 4.4 Kit Kat, Google has begun licensing Google Chrome proprietary software) separately from Android, but
usually bundled with (what most device vendors did). Since Android 5.0 Lollipop, the Web View browser that apps can use to
display web content without leaving the app has been separated from the rest of the Android firmware in order to facilitate
separate security updates by Google.
TV recording
Android TV supports capturing video and replaying it. [12]
Video calling
Android does not support native video calling, but some handsets have a customized version of the operating system that
supports it, either via the UMTS network (like the Samsung Galaxy S) or over IP. Video calling through Google Talk is available in
Android 2.3.4 (Gingerbread) and later. Gingerbread allows Nexus S to place Internet calls with a SIP account. This allows for
enhanced VoIP dialing to other SIP accounts and even phone numbers. Skype 2.1 offers video calling in Android 2.3, including
front camera support. Users with the Google+ Android app can perform video chat with other Google+ users through Hangouts
Connectivity
Android supports connectivity technologies including GSM/EDGE, Bluetooth, LTE, CDMA, EV-
DO, UMTS, NFC, IDEN and WiMAX.
Bluetooth
Supports voice dialing and sending contacts between phones, playing music, sending files (OPP), accessing the phone book
(PBAP), A2DP and AVRCP. Keyboard, mouse and joystick (HID) support is available in Android 3.1+, and in earlier versions
through manufacturer customizations and third-party applications. [14]

Q. What is activity:-

An Android activity is one screen of the Android app's user interface. In that way an Android activity is very similar to
windows in a desktop application. An Android app may contain one or more activities, meaning one or more screens.

Android Activity Lifecycle methods


Let's see the 7 lifecycle methods of android activity.

Method Description

on Create Called when activity is first created.


on Start Called when activity is becoming visible to the user.

On Resume Called when activity will start interacting with the user.

On Pause Called when activity is not visible to the user.

On Stop Called when activity is no longer visible to the user.

On Restart Called after your activity is stopped, prior to start.

On Destroy Called before the activity is destroyed.

Q. Describe android architecture:-

Linux kernel:
The android uses the powerful Linux kernel and it supports wide range of hardware drivers. The kernel is the
heart of the operating system that manages input and output requests from software. This provides basic
system functionalities like process management, memory management, device management like camera,
keypad, display etc the kernel handles all the things. The Linux is really good at networking and it is not
necessary to interface it to the peripheral hardware. The kernel itself does not interact directly with the user but
rather interacts with the shell and other programs as well as with the hard ware devices on the system.
Libraries:
The on top of a Linux kennel there is a set of libraries including open source web browser such as web kit,
library lab. These libraries are used to play and record audio and video. The SQ lite is a data base which is
useful for storage and sharing of application data. The SSL libraries are responsible for internet security etc.

Android Runtime:
The android runtime provides a key component called Dalvik Virtual Machine which is a kind of java virtual
machine. It is specially designed and optimized for android. The Dalvik VM is the process virtual machine in the
android operating system. It is software that runs apps on android devices.

The Dalvik VM makes use of Linux core features like memory management and multithreading which is in a
java language. The Dalvik VM enables every android application to run it own process. The Dalvik VM
executes the files in the .dex format.

Application frame work:


The application frame work layer provides many higher level services to applications such as windows
manager, view system, package manager, resource manager etc. The application developers are allowed to
make use of these services in their application.

Q. what is fragment in mobile application and how it is created:-

In Android, Fragment is a part of an activity which enables more modular activity design. It will not be wrong if we say
a fragment is a kind of sub-activity. It represents a behavior or a portion of user interface in an Activity. We can combine
multiple Fragments in Single Activity to build a multi panel UI and reuse a Fragment in multiple Activities. We always need to
embed Fragment in an activity and the fragment lifecycle is directly affected by the host activity’s lifecycle.

We can create Fragments by extending Fragment class or by inserting a Fragment into our Activity layout by declaring the
Fragment in the activity’s layout file, as a <fragment> element. We can manipulate each Fragment independently, such as add
or remove them. While performing Fragment Transaction we can add a Fragment into back stack that’s managed by the
Activity. Back stack allow us to reverse a Fragment transaction on pressing Back button of device. For Example if we replace a
Fragment and add it in back stack then on pressing the Back button on device it display the previous Fragment

Fragment coding:-

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

public class MainActivity extends FragmentActivity {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.news_articles);
    }
}

Q. What is Intent in Android?


An intent is a simple message object that is used to communicate
between android components such as activities, content providers, broadcast
receivers and services. Intents are also used to transfer data between activities.

Intents are used generally for starting a new activity using startActivity().
Use of Intent
1. For Launching an Activity
2. To start a New Service
3. For Broadcasting Messages
4. To Display a list of contacts in List View

Types of Intent in Android


Intent is of two types:
1. Implicit Intent
2. Explicit Intent
Implicit Intent
The implicit intent is the intent where instead of defining the exact components, you
define the action that you want to perform for different activities.
An Implicit intent specifies an action that can invoke any app on the device to be able
to perform an action. Using an Implicit Intent is useful when your app cannot
perform the action but other apps probably can and you’d like the user to pick which
app to use.
Syntax:
Intent i=new Intent();

i.setAction(Intent.ACTION_SEND);

There are some other standard actions that intents can use for launching activities.
Explicit Intent
An explicit intent is an Intent where you explicitly define the component that needs
to be called by the Android System. An explicit intent is one that you can use to
launch a specific app component, such as a particular activity or service in your app.

Syntax:

Intent I = new Intent(getApplicationContext(),NextActivity.class);

I.putExtra(“value1” , “This value for Next Activity”);

I.putExtra(“value2” , “This value for Next Activity”);

What information intent gives in android?

An Intent object carries information that the Android system uses to determine which component to start (such as the
exact component name or component category that should receive the intent), plus information that the recipient
component uses in order to properly perform the action.

Explain different types of intent


The Different Methods Used in Intent
 Action_Main
 Action_Pick
 Action_Chooser
 Action_Dial
 Action_Call
 Action_Send
 Action_SendTo

1. ACTION_MAIN
Use: Adds an action to an intent Filter.

<action android:name = “string”>

2. ACTION_PICK
Syntax:
It is using for picking the image from CAMERA or GALLERY.
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);

3. ACTION_CHOOSER
Use: It is used for choosing the image from the gallery.

Intent select = new Intent(Intent.ACTION_CAMERA);  send.setData(uri);


startActivity(Intent.createChooser(select,”Select an Image from Camera”));
4. ACTION_DIAL
Use – Display the phone dialer with the given number filled in.

String myPhoneNumber = “tel : 123456 ;

Intent next = new Intent (Intent.ACTION_DIAL, Uri.parse(myPhoneNumberUri));

startActivity(next);

5. ACTION_CALL
Use: Placing and immediate phone call
String data = “tel : 651234567”;

Intent myActivity = new Intent(Intent.ACTION_CALL, Uri.parse(myNumber);

startActivity(myActivity);

Permission Needed:

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

6. ACTION_SEND
Use: Sending Text content from one activity to other.

Intent sendIntent = new Intent();

sendIntent.setAction(Intent.ACTION_SEND);

sendIntent.putExtra(Intent.EXTRA_TEXT, “This is my text to Send”);

sendIntent.setType(“text/plain”);

startActivity(sendIntent);

 
7. ACTION_SENDTO
Use : Preparing an SMS. The text is supplied as an Extra element. The intent excepts
such as values to be called “sms_body”

Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(“smsto : 15555215556 “));

intent.putExtra(“sms_body”,”are we playing cricket today?”);

startActivity(intent);

 
Q. what is view and view group in mobile application:-

Android View
The View is a base class for all UI components in android. For example, the EditText class is used to accept the input from users in android
apps, which is a subclass of View.
 
Following are the some of common View subclasses that will be used in android applications.
 

 TextView
 EditText
 Button
 CheckBox
 RadioButton
 ImageButton
 Progress Bar
 Spinner

Like these we have many View subclasses available in android.

Android View Group


The View Group is a subclass of View and it will act as a base class for layouts and layouts parameters. The View Group will provide invisible
containers to hold other Views or View Groups and to define the layout properties.
 
For example, Linear Layout is the View Group that contains a UI controls like button, text view, etc. and other layouts also.
 
Following are the commonly used View Group subclasses in android applications.
 

 Linear Layout
 Relative Layout
 Table Layout
 Frame Layout
 Web View
 List View
 Grid View

Both View and View Group subclasses together will play a key role to create a layout in android applications.

Why layout is created using xml file:-

A layout defines the structure for a user interface in your app, such as in an activity. All elements in the layout are built using
a hierarchy of View and ViewGroup objects. A View usually draws something the user can see and interact with. Whereas
a ViewGroup is an invisible container that defines the layout structure for View and other ViewGroup objects

Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way
you create web pages in HTML — with a series of nested elements.

Each layout file must contain exactly one root element, which must be a View or ViewGroup object. Once you've defined the
root element, you can add additional layout objects or widgets as child elements to gradually build a View hierarchy that
defines your layout. For example, here's an XML layout that uses a vertical LinearLayout to hold a TextView and a Button
Q. Related layout in android:-

Android RelativeLayout enables you to specify how child views are positioned relative to each other. The position of each view can be
specified as relative to sibling elements or relative to the parent.

Relative Layout

RelativeLayout Attributes
Following are the important attributes specific to RelativeLayout −
Sr.No Attribute & Description
.

1
android:id

This is the ID which uniquely identifies the layout.

2
android:gravity

This specifies how an object should position its content, on both the X and Y axes. Possible
values are top, bottom, left, right, center, center_vertical, center_horizontal etc.

3
android:ignoreGravity

This indicates what view should not be affected by gravity.


4 android:layout_above

Positions the bottom edge of this view above the given anchor view ID and must be a
reference to another resource, in the form "@[+][package:]type:name"

5 android:layout_alignBottom

Makes the bottom edge of this view match the bottom edge of the given anchor view ID
and must be a reference to another resource, in the form "@[+][package:]type:name".

6 android:layout_alignParentBottom

If true, makes the bottom edge of this view match the bottom edge of the parent. Must
be a boolean value, either "true" or "false".

What is a Contextual Menu?


Definition: A contextual menu is a type of menu that appears on demand and contains a small set of relevant
actions related to a control, an area of the interface, a piece of data in the application, or a view of the
application. Usually, this context is given by the current selection or has otherwise been specified by the user
before invoking the contextual menu.

In Microsoft Word, highlighting a passage of text, holding down the  Control  key, and clicking the mouse
revealed a contextual menu that contained only commands related to the selected piece of data.

Q. Android application demonstrate context menu

 Step 1: Open or Create a Project. ...


 Step 2: Import the Android Resources. ...
 Step 3: Add a UI Element to Long-Press. ...
 Step 4: Create a Menu Resource. ...
 Step 5: Register for the Context Menu. ...
 Step 6: Use Your Menu Resource.
Q. List different notification techniques used to notify the user:-

Displaying notification is one of the most important features in an Android app. Notification are short
messages which appear on home screen of the device. In this example you will learn how to
programatically create and display a Notification from your app which will work for all versions of
Android.

Displaying a Simple Notification:

Before implementing it is important to understand what are various components in a Notification design
(later we can check how to implement each of them)

Below is the latest default design of an Android Notification . You can only define content of various
components in the design( You cannot change the UI design itself as it defined by system templates)

Courtesy: Google
Dev

1. Small Icon
2. App Name (Given by System)
3. Timestamp
4. Large Icon
5. Content Title
6. Content Text

Issuing the Notification

Merely creating a notification object wont display it, to display the  notification you will need to
call notify() on the NotificationManager object as shown below. As you can see a unique integer identifier
is also required while issuing the notification. This integer acts as a unique identifier for that particular
notification

1. // Unique identifier for notification


2. public static final int NOTIFICATION_ID = 101;
3.
4. //This is what will will issue the notification i.e.notification will be visible
5. NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);
6. notificationManagerCompat.notify(NOTIFICATION_ID, notification);

Q. Write android application to check whether the network is available or not

In android, by using the ConnectivityManager class we can easily determine whether the device connected to the network/internet or not
and also we can determine the type of internet connection currently available i.e. whether it’s mobile data or Wi-Fi.
 
To get the internet connection status, our app must acquire the INTERNET and ACCESS_NETWORK_STATE permissions. For that, we need
to add the following permissions in the android manifest file like as shown below.
 
<manifest>
    ....
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    ....
</manifest>

To find the MAC address of your Android phone or tablet:

1. Press the Menu key and select Settings.


2. Select Wireless & networks or About Device.
3. Select Wi-Fi Settings or Hardware Info.
4. Press the Menu key again and choose Advanced. Your device's wireless adapter's MAC address should be
visible here.

Q. what is web server in android

A  web server, PHP programming language and the database MySQL. KSWEB allows you to organize a platform for
running and debugging Web applications (sites) in your Android device. ... To start the server it is enough to run our
application, select, if necessary, port and the root directory.

Q. How you can display current location of user in android application

Steps to get location in Android

1. Provide permissions in manifest file for receiving location update.


2. Create LocationManager instance as reference to the location service.
3. Request location from LocationManager.
4. Receive location update from LocationListener on change of location.

To access current location information through location providers, we need to set permissions with android

manifest file.

<manifest ... >

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


<uses-permission android:name="android.permission. ACCESS_COARSE_LOCATION"
/>

<uses-permission android:name="android.permission.INTERNET" />

</manifest>

Q. Android Telephony Manager Tutorial


The android.telephony.TelephonyManager class provides information about the telephony services such as subscriber id, sim
serial number, phone network type etc. Moreover, you can determine the phone state etc.

Q. which classes are provided by android framework to play audio and video in
android:-

Android provides many ways to control playback of audio/video files and streams. One
of this ways is through a class called Media Player.
Android is providing Media Player class to access built-in mediaplayer services like
playing audio,video e.t.c. In order to use MediaPlayer, we have to call a static
Method create() of this class. This method returns an instance of MediaPlayer class.
Its syntax is as follows −
MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.song);
The second parameter is the name of the song that you want to play. You have to
make a new folder under your project with name raw and place the music file into it.
Once you have created the Mediaplayer object you can call some methods to start or
stop the music. These methods are listed below.
mediaPlayer.start();
mediaPlayer.pause();
On call to start() method, the music will start playing from the beginning. If this method
is called again after the pause() method, the music would start playing from where it is
left and not from the beginning.
In order to start music from the beginning, you have to call reset() method. Its syntax is
given below.
mediaPlayer.reset();

Classes of audio/videos display:-

Sr.No Method & description

1
isPlaying()

This method just returns true/false indicating the song is playing or not
2
seekTo(position)

This method takes an integer, and move song to that particular position millisecond

3
getCurrentPosition()

This method returns the current position of song in milliseconds

4
getDuration()

This method returns the total time duration of song in milliseconds

5
reset()

This method resets the media player

6
release()

This method releases any resource attached with MediaPlayer object

7
setVolume(float leftVolume, float rightVolume)

This method sets the up down volume for this player

8
setDataSource(FileDescriptor fd)

This method sets the data source of audio/video file

9
selectTrack(int index)

This method takes an integer, and select the track from the list on that particular index

10
getTrackInfo()

This method returns an array of track information

Вам также может понравиться