You are on page 1of 8

8. What is Pending Intent?

PendingIntent lets us pass a future Intent to another application and allow that application to
execute that Intent as if it had the same permissions as our application, whether or not our
application is still around when the Intent is eventually invoked.

9. What type of permission is required for Wi-Fi network?

To perform network operations in your application, your manifest must include the
following permissions:

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


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

10 What is Open GL?

Android includes support for high performance 2D and 3D graphics with the Open Graphics
Library (OpenGL®), specifically, the OpenGL ES API. OpenGL is a cross-platform
graphics API that specifies a standard software interface for 3D graphics processing
hardware.

11. Define the term UI element?

In android UI or input controls are the interactive or View components that are used to
design the user interface of an application. In android we have a wide variety of UI or
input controls available, those are TextView, EditText, Buttons, Checkbox, Progressbar,
Spinners, etc.

12. Explain the use of custom view.

A well-designed custom view is much like any other well-designed class. It encapsulates a
specific set of functionality with an easy to use interface, it uses CPU and memory
efficiently, and so on. In addition to being a well-designed class, though, a custom view
should: Conform to Android standards

13. Write a short note on Rating Bar.

Android RatingBar can be used to get the rating from the user. The Rating returns a
floating-point number. It may be 2.0, 3.5, 4.0 etc.

Android RatingBar displays the rating in stars. Android RatingBar is the subclass of
AbsSeekBar class.

The getRating() method of android RatingBar class returns the rating number.
14. Explain the local and remote binding concepts of Services. 04

Local service means it runs in the same process probably in the same application. You
can start a service using the method startService() and you can stop the service by using
the method stopService(). These two life cycle methods or Service And remote service are
generally run in a different application. you can access them by writing AIDL Interfaces
and you can attach to a remote service by using binder.

Remote Service
This type of services normally design and implement software functionality to be used by
other apps. Android system services (wifi/gps/usb/etc.)are the main examples in this
category. If you need provide functionality to be used by other apps, you need to
develop a remote service which implements remote binding, intent (through
startCommand) or other IPC mechanism.

15. Define the procedure to create notification.

Notifications provide short, timely information about events in your app while it's not
in use. This page teaches you how to create a notification with various features for
Android 4.0 (API level 14) and higher. For an introduction to how notifications appear
on Android, see the Notifications Overview. For sample code that uses notifications,
see the Android Notifications Sample.

Notice that the code on this page uses the NotificationCompat APIs from the Android
support library. These APIs allow you to add features available only on newer
versions of Android while still providing compatibility back to Android 4.0 (API level
14). However, some new features such as the inline reply action result in a no-op on
older versions.

16. Outline the process of interaction among activity

17. Explain the make-up of CONTENT_URI.

Content" can come from anywhere in your device. The system as well as every app can
provide content.

Those Uris act similar to http urls and help identify the data source that provides the
information (http://phonebook.com). An Uri goes in practice 1 step further and identifies at
least the table inside a database (http://phonebook.com/by_name), sometimes even the exact
item. (e.g. http://phonebook.com/by_name/macdonjo) - or like content://com.android.contacts/123 in
reality.

So CONTENT_URI does nothing besides telling ContentResolver what data to fetch.

P.s. the code you've found there looks pretty dated. Both managing cursor as well as
the People convenience class are deprecated for a while now.
18. Write an android program for Phone call.

1. <?xml version="1.0" encoding="utf-8"?>


2. <android.support.constraint.ConstraintLayout xmlns:android="ht
tp://schemas.android.com/apk/res/android"
3. xmlns:app="http://schemas.android.com/apk/res-auto"
4. xmlns:tools="http://schemas.android.com/tools"
5. android:layout_width="match_parent"
6. android:layout_height="match_parent"
7.
8. tools:context="abu.call.MainActivity" >
9. <RelativeLayout
10. android:layout_width="match_parent"
11. android:layout_height="wrap_content"
12. android:orientation="vertical">
13.
14.
15. <TextView
16. android:id="@+id/textView1"
17. android:layout_width="wrap_content"
18. android:layout_height="wrap_content"
19. android:text="Dial No." />
20. <Button
21. android:id="@+id/button1"
22. android:layout_width="wrap_content"
23. android:layout_height="wrap_content"
24. android:layout_alignLeft="@+id/textView1"
25. android:layout_below="@+id/textView1"
26. android:layout_marginLeft="44dp"
27. android:layout_marginTop="84dp"
28. android:text="Call" />
29. <EditText
30. android:id="@+id/editText1"
31. android:layout_width="wrap_content"
32. android:layout_height="wrap_content"
33. android:layout_alignLeft="@+id/textView1"
34. android:layout_below="@+id/textView1"
35. android:layout_marginLeft="18dp"
36. android:ems="10" >
37. <requestFocus />
38. </EditText>
39. </RelativeLayout>
40. </android.support.constraint.ConstraintLayout>

19. How to create a Broadcast receiver?

Creating the Broadcast Receiver:


class AirplaneModeChangeReceiver:BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
// logic of the code needs to be written here
}
}
20. Write android code for creating Anolog Clock.

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout

xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity">

<AnalogClock

android:layout_marginTop="20dp"

android:layout_marginLeft="120dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

<DigitalClock
android:layout_marginLeft="140dp"

android:textSize="25dp"

android:layout_marginTop="300dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

</RelativeLayout>

Output:

22. Illustrate Fragment life cycle states and respective callback methods.

Fragment lifecycle states and callbacks


When determining a fragment's lifecycle state, FragmentManager considers the
following:

 A fragment's maximum state is determined by its FragmentManager. A fragment cannot


progress beyond the state of its FragmentManager.
 As part of a FragmentTransaction, you can set a maximum lifecycle state on a fragment
using setMaxLifecycle() .

A fragment's lifecycle state can never be greater than its parent. For example, a
parent fragment or activity must be started before its child fragments. Likewise, child
fragments must be stopped before their parent fragment or activity. Figure 1 shows
each of the fragment's Lifecycle states and how they relate to both the fragment's
lifecycle callbacks and the fragment's view Lifecycle.

As a fragment progresses through its lifecycle, it moves upward and downward


through its states. For example, a fragment that is added to the top of the back stack
moves upward from CREATED to STARTED to RESUMED. Conversely, when a
fragment is popped off of the back stack, it moves downward through those states,
going from RESUMED to STARTED to CREATED and finally DESTROYED.

24. Write android code for creating option menu.

<menu
xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

tools:context=".MainActivity">

<item

android:id="@+id/message"

android:icon="@android:drawable/ic_menu_send"

app:showAsAction="always"

android:title="message"/>

<item

android:id="@+id/picture"

android:icon="@android:drawable/ic_menu_gallery"

app:showAsAction="always|withText"

android:title="picture"/>

<item

android:id="@+id/mode"

android:icon="@android:drawable/ic_menu_call"

app:showAsAction="always"

android:title="mode"/>
<item

android:id="@+id/about"

android:icon="@android:drawable/ic_dialog_info"

app:showAsAction="never|withText"

android:title="calculator"/>

<item

android:id="@+id/exit"

app:showAsAction="never"

android:title="exit"/>

</menu>

25. Write down the steps for using Broadcast receivers.


Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start
a New Project in Android Studio.
Step 2: Working with the activity_main.xml file
Go to the activity_main.xml file and refer to the following code. Below is the
code for the activity_main.xml file.
Step 3: Working with the MainActivity file
Go to the MainActivity file and refer to the following code. Below is the code
for the MainActivity file. Comments are added inside the code to understand
the code in more detail.
Step 4: Create a new class
Go to app > java > your package name(in which the MainActicity is
present) > right-click > New > Kotlin File/Class and name the files
as AirplaneModeChangeReceiver. Below is the code for
the AirplaneModeChangeReceiver file. Comments are added inside the
code to understand the code in more detail.

You might also like