SlideShare une entreprise Scribd logo
1  sur  84
Android in Hindi
Third Edition
V.K. Sharma
www.besthinditutorials.com
V.K. Sharma
www.besthinditutorials.com
12/1/2015
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Android in Hindi
Third Edition
V.K. SHARMA
www.besthinditutorials.com
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
©Copyright 2015 by www.besthinditutorials.com
This EBook may not be duplicated in any way without the express written consent of the
publisher, except in the form of brief excerpts or quotations for the purpose of review. The
information contained herein is for the personal use of reader and may not be incorporated
in any commercial programs, other books, databases, or any kind of software without written
consent of the publisher. Making copies of this EBook or any portion thereof for any purpose
other than your own is violation of copyright laws.
This edition has been published by www.besthinditutorials.com
Limits of Liability/disclaimer of Warranty: The author and publisher have used their best
efforts in preparing this EBook. www.besthinditutorials.com makes no representation or
warranties with respect to the accuracy or completeness of the contents of this book, and
specifically disclaims any implied warranties which extend beyond the descriptions contained
in this paragraph. No warranty may be created or extended by sales representatives or
written sales materials. The accuracy and completeness of the information provided herein
and the opinions stated herein are not guaranteed or warranted to produce any particular
results and the advice and strategies contained herein may not be suitable for every
individual. www.besthinditutorials.com shall not be liable for any loss of profit or any other
commercial damages, including but not limited to special, incidental, consequential, or other
damages.
Trademarks: All brand names and product names used in this EBook are trademarks,
registered trademarks, or trade names of their respective holders.
www.besthinditutorials.com is not associated with any product or vendor mentioned in this
EBook.
Reprint Edition: 2013
Published By: www.besthinditutorials.com
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Contents
1. INTRODUCTION TO ANDROID
1.1. History of Android
1.2. Features of Android
1.3. OO principles of java
1.4. Java vs. c and c++
2. ANDROID DEVELOPMENT TOOLS
2.1. Creating an application
2.2. Hello world program
3. ANDROID COMPONENTS
3.1. Activity
3.2. Services
3.3. Content provider
3.4. Broadcast receiver
4. ACTIVITY
4.1. Introduction
4.2. Creating an activity
4.3. Example
5. SERVICES
5.1. Introduction
5.2. Creating a service
5.3. Example
6. CONTENT PROVIDERS
6.1. Introduction
6.2. Creating a content provider
6.3. Accessing a content provider
6.4. Example
7. BROADCAST RECEIVER
7.1. Introduction
7.2. Creating broad cast receiver
7.3. Example
8. INTENTS
8.1. Introduction
8.2. Working of intents
8.3. Creating intents
9. VIEWS
9.1. Introduction
9.2. Types of views
9.3. Adding views to activity
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
10. FRAGMENTS
10.1. Introduction
10.2. Types of fragments
10.3. Creating fragments
11. LAYOUTS
11.1. Introduction
11.2. Attributes of layouts
11.3. Types of layouts
12. RESOURCES
12.1. Introduction
12.2. Types of resources
12.3. Supplying resources
13. DIALOGS
13.1. Introduction
13.2. Creating dialogs
13.3. Adding buttons
13.4. Adding lists
14. NOTIFICATIONS
14.1. Introduction
14.2. Creating notifications
14.3. Taking actions
15. MENUS
15.1. Introduction
15.2. Options menus
15.3. Context menus
15.4. Popup menus
16. BUTTONS
16.1. Introduction
16.2. Steps to create buttons
16.3. Creating buttons
16.4. Desingning buttons
17. TEXT FIELDS
17.1. Introduction
17.2. Creating text fields
17.3. Input types
18. SPINNERS
18.1. Introduction
18.2. Defining spinners
18.3. Creating spinners
18.4. Responding to selections
19. SEARCH INTERFACE
19.1. Introduction
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
19.2. Creating search interface
20. FILE SYSTEM
20.1. Introduction
20.2. Core directories
21. STORAGE SYSTEM
21.1. Introduction
21.2. Storage options
21.2.1. Shared preferences
21.2.2. Internal storage
21.2.3. External storage
21.2.4. SQLite database
21.2.5. Network Connection
22. Index
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Preface
The idea of writing a book about Android Development in Hindi can be somewhat futile at
times, considering the pace at which android continues to expand, morph and change. What
started out as a book project two years ago has now become a series of updates to the
original work with the page count nearly double the original project and that after making
hard decisions about what to leave out of the book to make sure it gets liked.
This update to Android in Hindi represents our latest effort to provide coverage on important
Android Development topics, namely the expansion into the tablet.
Like many things in life, the only constant is change, but by now we are somewhat
accustomed to the rapid-fire environment of Android Development. To the end, we have
ensured that all the programs work with android studio as well as without android studio.
The third edition is written by Vipin Kumar Sharma. Thank you for learning and collaborating
with us.
VIPIN KUMAR SHARMA
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Acknowledgement
Writing a third edition of Android in Hindi feels somewhat like the old saying about weddings:
“Something old, something new…” The deadline for the third edition did not become any
easier as at last count there are still only 24 hours in the day. And as for something new it
seems as though android’s pace of innovation is continuing to match its adoption rate by
users around the globe.
In particular, we’d like to acknowledge and thank everyone at www.besthinditutorials.com.
Firstly I would like to thank our EBook Designers and editors, who have been involved in
every aspect of now three editions of this project. I would also like to thank our publisher to
bring this masterpiece in EBook format.
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
About this book
Android in Hindi, Third Edition is a revision and update of the second edition published in
2013. This third edition adds new content related to android 5.0. Like its predecessors, this
book covers important beginner topics such as “What is Android?” and installing and using
the development environment. We than advance to practical working examples of core
programming topics any developer will be happy to have at the ready on the reference shelf.
The remaining chapter’s present detailed example applications covering advanced topics,
including Widgets and UI.
Although you can read the book from start to finish, you can also consider it a few books in
one. If you are new to android focus first on beginning chapters. With the foundation you can
work your way up to last chapter.
Who should read this book?
We wrote this book for professional programmers and hobbyists alike. Many of the concepts
can absorbed without specific android knowledge. If you have c, c++ or c# knowledge, you
will be able to follow the examples.
Prior android studio experience is helpful, but not required. A number of good resources are
available on java and android to augment the content of this book.
And lastly the person who is willing to learn java in his mother tongue Hindi should read this
book.
Road map
1. BASIC – FIRST 10 CHAPTERS CONTAIN BASIC INFORMATION REGARDING ANDROID
PROGRAMMING.
2. INTERMEDIATE – NEXT 10 CHAPTERS ARE SOMEWHAT OF INTERMEDIATE LEVEL AND
NECESSARY ANDROID TOPICS.
3. ADVANCED – REMAINING CHAPTERS COVERS SOME ADVANCED TOPICS OF ANDROID
DEVELOPMENT.
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 1
Introduction
This chapter covers
 Introduction to android
 Android versions
 Features of android
 Android platform
Introduction to android
Android एक ओपन linux based ऑप . ए क 2009 प क .
Android क Open Handset Alliance न प क , क औ क पन क
ओपन एक organizations क प क न
क ए क क . ए न प क क
.
Android versions
ए क क क 10 versions आ क . ए क version ए क नए ऐ
क . आ ए क versions क नन क क . Android Versions
आपक प न ए .
Android 5.0 Lollipop - ए क version 12 न 2014 क क . ए क
version guest login support, 64 bit CPU support औ 15 new language support कई नए
ऐ क ए .
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Android 4.4 KitKat - ए क version 31 2013 क क . ए क
version audio monitoring, GPS support औ wireless printing कई नए ऐ क ए
.
Android 4.1 JellyBean - ए क version 9 ई 2012 क क . ए क
version audio chaining, group messaging औ security enhancement नए ऐ क
ए .
Android 4.0 Ice Cream Sandwich - ए क version 18 2011 क क
. ए क version inbuilt photo editor, ability to access apps directly from lock screen,
wifi direct or face unlock कई नए ऐ क ए .
Android 3.0 Honeycomb - ए क version 22 2011 क क . ए
क version home screen widget औ support for multi core processor नए ऐ
क ए .
Android 2.3 Gingerbread - ए क version 6 2010 क क .
version download manager, improved user interface, efficient battery औ improved gmail
app कई ऐ क ए .
Android 2.2 Froyo - ए क version 20 ई 2010 क क . ए क
version क USB tethering, adobe flash support औ wifi hotspot functionality नए क
क .
Android 2.0 Eclair - ए क version 26 2009 क क . version
bluetooth support औ google map कई नए features ऐ क ए .
Android 1.6 Donut - ए क version 15 2009 क क . ए क
version gallary, camera औ quick search box कई ऐ क ए .
Android 1.5 CupCake - ए क version 27 2009 क क . ए क
version auto-rotation, copy and paste, animated screen transition औ support for video
recording include क ए .
Features of android
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
ए एक आ . Android features ए क
न . ए क क न न -
1. User Interface - ए एक औ क क
क न आ न .
2. Multiple Language Support - ए क प क .
3. ए messaging, web applications औ video calling क प क .
4. Media - ए media formats(mp3, jpg, mp4, flv) क प क .
5. Connectivity - ए bluetooth, wifi औ hotspot क न क कन
क .
6. Storage - ए न क ए ए क न क आप क
न क क .
7. Applications - ए आप पन न प applications क .
8. Open Source - ए एक ओपन ऑप क क प क ए
.
Android platform
ए एक एन न क ए प क क ई न
. Android platform क न आ न क न -
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
 Linux based OS - न प न क ए एक प
एन न . न kernel एक abstraction क आप
क पन क प क क .
न ऑप कप न ए c औ c++ प क ए
 Dalvik Virtual Machine - क ए virtual न . आप ए क ई
ए क न न . आप ए क न क क क compile क क
क क . क क क ए क क क
dex files क . क क क न क क क न क ए
java virtual machine क न dex files क न क क क न क
ए delvik virtual न क .
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
 User Interface - ए क . ए क
ए क क क प क क .
 Applications - ए क न क ए न क क ए प न .
पन प क क क क . ए क क
प क .
 Libraries - ए औ क ए
प क ए .
 Frameworks - ए क क प क ए क क
क ए क न ए क ए कप न ऐ क क ए क न
न न क क क न क ए क न न क न .
 Multimedia support - ए प क ए औ
क .ए आप क क क .
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 2
Android Development Tools
This chapter covers
 Android SDK
 Android debug bridge
 Gradle
 Android studio
 Android runtime and delvik
Android SDK
Android SDK नक आपक ए ए क न ए क न , क प क न
औ ए क न क पक क न क ए प Android SDK आपक क क
प , प , एक औ ए क न प क न क ए
. ए क न प क औ क न प न क .
Android Debug Bridge
ADB android SDK क एक क न क आप पन ए क न क
क प न क क औ क क . एक
एक , एक औ एक न (daemon ) . प
न प न , प न प एक क क न औ न
प क क न .
Gradle
Gradle एक ए . क ए क न क (पक ) क न क
. क औ क आ न reuse क क . एक ए क न क कई variants
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
आ न ए क क . क क क न आ न . Gradle
आ न IDE क .
Android studio
Android Studio ए ए क न प क न क ए ऑ IDE . Android Studio क क
न ए -
 Android Studio .
 ए औ एक कई apk आप android studio generate क क .
 क न ए क न क न क ए ए क प क .
 Android Studio एक आ ए क आप औ प क क
ए क क .
 Android Studio performance, usability औ version compatibility क क
क न क ए lint क क .
 Android Studio google cloud platform क ए built in support क .
Android Studio क आप Eclipse IDE क क . क ए आपक ADT
plugin क आ क कन क Android Studio Official IDE ए न android
studio क क
Android run time and Dalvik
न ए ए क न क न न क ए एन न क . कन ए 5.0
ART क क . औ प क versions Dalvik क न क क . ART
Dalvik क Dex Files क execute क . ART औ Dalvik एक एक क प
, ए क ई application Dalvik क ए प क ART आ न क
.
ART Ahead-Of-Time( AOT ) कप न क introduce क . ART न
verification delvik .
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 3
Android Components
This chapter cover
 Activity
 Services
 Content provider
 Broadcast receiver
Android Activity
आपक application GUI Screen activity . एक GUI Screen औ activity
one to one relationship . MVC paradigm controller view क control क
क एक activity आपक android application GUI Screen क control क .
आप पन android application न GUI Screen आपक न activity create
क न . activity एक GUI Screen क display क .
user GUI Screen क क ई events generate क activity न events क handle
क न क ए responsible . कई activity system generated events क handle क .
GUI Screen elements display क न क ए activity views क . view एक different
element क represent क . Views क न नक आप Android in Hindi:Views
tutorial क .
Android activity create क न क ए आपक Activity class क extend क न . क
न -
Public class yr_cls_nm extends Activity
{
}
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Android Service
क application क क execute न service क implement क न
. आप एक service launch क क औ क प न प terminate क
क . Services background run औ नक user interface न . एक android
service create क न क ए आपक Service class क extend क न . क न
-
Example
public class yur_cls_nm extends Service
{
}
Android broadcast receiver
Intents क notification प न क ए एक application क क broadcast receiver क register
क न .
क application क register क न क ए आपक AndroidManfest.xml file receiver element
क include क न प . औ क name attribute पन class क न प क न .
प आपक dot operator (.) न . क न -
Example
<receiver android:name=".yourclassname">
</receiver>
receiver tags आप intent-filter क क .
Example
<receiver android :name =".yourclassname ">
<intent-filter>
<action android:name ="action_name">
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
</intent-filter>
</receiver>
Android content provider
एक application पन data क application क share क न ऐ
content provider क क क क application क data क content provider
store . एक application क application क data क access क न
application क content provider क ए क . Content provider क methods
क application क access क न क permission .
4 primary components android application . Android components क न
android क न क ए .
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 4
Activity
This chapter covers
 Introduction
 Starting an activity
 Activity life cycle
 Launcher activity
 Creating new activity
 Destroying an activity
Introduction to activity
आप क application एक activity क आप न activities क navigate क
, न एक activity activity activity पन life cycle क different stages
क ए आपक activity start foreground औ user क प focus
प process क न android system क life cycle methods क call क
user क ई activity start क android system activity क life cycle methods क call
क औ आपक प activity background
Life cycle methods आप decide क क क user प आ आपक
activity क behave क क ए आप एक player न user क
activity प video streaming क न ए कन आप एक music player न
आप music क background play क क .
Starting an activity
programming paradigms क ई ए क न main Android
android system activity क life cycle methods क initiate क Activity क start क न क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
ए methods क sequence औ activity क close क न क ए methods क
sequence
Understanding activity life cycle methods
Activity क life cycle क न android system set of methods क call क क activity क
life cycle एक step pyramid क Activity life cycle क stage separate
क android system activity क start क method activity क एक step forward क
औ activity top क प Activity क top stage activity running stage औ
visible user क interact क क
user activity क क activity क stages pyramid न क move क न
औ last stage क activity destroy क cases activity wait क
क user application प switch क activity background wait क औ
user प आ activity resume
आप क application क complexity क ए न क आप life cycle methods
implement क न कन क आप क methods आ औ आपक
ए क न क behavior क ए आप methods implement क क Activity क life
cycle stages क क information न
Created - stage onCreate() activity create क user आपक
application क icon प क क
Started - stage onStart() activity start क
Resumed - stage activity running stage औ user क visible
Paused - stage activity paused user क application switch क
Stopped - stage activity stopped
Destroyed - stage activity destroyed
Launcher activity
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
क ई user आपक ए क न क icon क click क android system activity क
onCreate() क call क आपन launcher declare क Launcher activity
activity आपक ए क न क main activity आपक ए क न कई activities
क कन प activity user क visible आपन launcher main declare
क
क न activity main activity आप AndroidManifest.xml declare क क
Main activity क <intent-filter > क declare क न ए action MAIN औ
category launcher
MAIN action launcher category defined न आपक application क icon न
Example
Creating a new activity
applications activities न user क perform क
activity main activity user क ए क न icon क क क न create क ई
activity आपक ए क न user interact क ए create क , android system
activity क create क न क ए onCreate() method क क
आपक onCreate() क implement क न , आप application क startup logic
प क क क activity क प life cycle क एक क क ए
आप पन implementation user interface define क क औ क variables instantiate
क क
onCreate() method क execution , android system onStart() औ
onResume() method क क क आपक activity created औ started stages प क
न आ Technically activity onStart() क क visible कन क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
onResume() method क activity क resume state activity क
resume state क क change न
Destroying the activity
Activity life cycle क प onCreate() औ last onDestroy()
Android system आपक activity प क क क क signal क
आपक activity android system क memory completely remove न
applications क onDestroy() क implement क न क न क
local references activity क कन आपक ए क न background
threads आपक onDestroy() method क implement क न ए
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 5
Services
This chapter covers
 Introduction
 Declaring service
 Creating a service
o Started service
o Bounded service
Introduction to android services
प क आप न क service आ न क service न -
 एक service separate न आपक ए क न क प
 एक service thread न
आ service -
 Service एक facility आप android system क क क आप क ई क
background क न
 Service एक facility एक ए क न पन क functionality applications
क expose क क
 service क <service> declaration AndroidManifest.xml file न ए
Services क आप context.startService() औ context.bindService() क
क
 service component ए android system component क initiate क
औ क onCreate() क क क . life cycle method execute
service प depend क क क क क complete क न
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
एक service क 2 forms क
Started - एक service started service क क ई component startService() क
क एक न क service क execute ए क न
component destroy operation क प service automatically stop
Bounded - एक ए क न bound क ई component bindService() क क क
service क bind क एक bound service client server interface क
component service क interact क क
एक service create क न क ए आपक एक create क न प base Service
क extend क . एक service callback आप implement क क
औ appropriate stage प पन क क प क क क service क आप 2
क क एक आप startService() क क क आप bindService() क क
क Service base क methods क आप पन क
implement क क क important न ए -
onStartCommand() - Android system क क क क ई component
क क ई activity startService() क क क service क start क न क ए request क
क service औ क execute आप
क implement क stopService() क क क service क प क न आपक
onBind() - Android system क क क ई component bindService()
क क क service क bind न आप क implement क आपक एक
interface क न ए clients service communicate क क
onCreate() - Android system method क क क service ए
एक क
onDestroy() - Android system क क क service पन क प क
औ destroy
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
क ई component service क startService() क क क क service क
न क stopSelf () क क क क प न क
component stopService() क क क service क प क
क ई component service क bindService() क क क क service क
न क क component service bound service clients unbound
android system service क destroy क
Android system service क forcefully stop क memory क औ क
user focus activity क ए resources क न
Declaring service in AndroidManifest.xml file
Activities क आपक services क AndroidManifest.xml file क न
Service क क न क ए आप <service> ए क <application> ए क child क
क
औ attribute आप service ए include क क औ properties क न
क क service क क न क ए permissions औ process service न
आप न क क android : name attribute आप service specify क
Creating a service
Started service
एक started service service components startService() क क क
क service start क एक life cycle क न component
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
क न component destroy service क न
Started service create क न क ए प 2 available -
Service - services क आप क ए क
क आप services क क क न क ए एक न thread ए क क by default service
main thread क क ऐ न आपक activity क performance slow
IntentService - Service क sub class . request क क न क ए class एक
worker provide क . कन एक एक request क क
आपक ए क न एक requests क क न न न IntentService
क implement क न आपक ए ऑ न
आ नन क क क आप क component activity क क क क
-
क component service क न क ए आप startService() intent प क क
Android system service क onStartCommand() क क औ intent प क
Example
Intent yrIntent = new Intent(this, yrclass.class);
startService(yrIntent);
आ क service क stop क क -
Started service क stop क न क android system क न . Service क
stopSelf() method क क क क stop क न क ई component
stopService() क क क service क stop क क
Bounded Service
एक bounded service service क components bindService() क
क क bind आपक bound service create क न ए आप क activity औ
components service क interact क क Bound service क आप पन ए क न
क क functionality ए क न क expose क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Bound service ए क न क ए आपक Service क onBind() method implement क न
एक IBinder return क service क communication क ए interface
define क
components bindService() क क क interface क क service
bounded components destroy न क क service destroy न
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 6
Content Provider
This chapter covers
 Introduction
 Accessing content providers
 Creating content providers
Introduction to content provider
आप पन application क applications क share क न आपक पन
application content provider create क न
Content providers क access क manage क Content providers क encapsulate
क औ क application security provide क
Content Provider create क न क ए आपक Content-Provider class क extend क न
class Content-Provider क extend क क ऑ क provider object क .
आप content provider data access क न क ए आपक Content-Resolver
क object क न Content provider आप एक client क access क
Content-Resolver provider object communicate क .
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
एक content provider applications क tables क form present क row
क type क represent क औ column data क एक part क represent क
क ई application क application access क न Content-
Resolver क एक client क application क provider object क request
क provider object request प action , औ results प क database
query क न
आप applications क data share न क न आपक content provider
create क न क आ क न कन आप पन ए क न क search क न
आपक content provider क
Accessing content provider
क न आपक प content provider access क न क ए आपक Content-
Resolver class क object क न Content-Resolver object क methods
provider object same न क methods क क क Content-Resolver object क methods
क आप क basic operations क create, retrieve, update औ delete प क
क
Content-Resolver methods Content-Provider ए आप
Content-Resolver क ई method क क method same न क क Content-
Provider क क
क ए आपक application content क access क न क ए Content-Resolver query()
method क क Content-Provider क query() method क क क Content
provider न methods न ए
Content provider available आप क न data access क न आपक
define क न क ए आप content U-R-I क क क Content U-R-I U-R-I
content provider क identify क Content U-R-I प आप content
provider क न आप table access क न क न
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 7
Broadcast Receivers
This chapter covers
 Introduction
 Creating broadcast receivers
 Registering broadcast receivers
Introduction to broadcast receivers
Broadcast receivers android components नक आप applications
औ system generate न events क notification प क
क event क नक प न क ए आपक application क event क ए क
register क न प क ई application ऐ एक broadcast receiver ए क क क क
क ई event generate android system न application क notify क
न event क ए क क
Creating broadcast receivers
Broadcast receivers ए क न क ए आपक BroadcastReceiver क extend क न
BroadcastReceiver क onReceive() क आप पन implement क क
onReceive() method आप न क क event receive क न क आप क न
Example
yourclasss extends BroadcastReceiver
{
@Override
public void onReceive(Content context, Intent intent)
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
{
//your implementation of onReceive() method.
}
}
Registering broadcast receivers
Broadcast receiver ए क न क आपक intent क ए register क न ऐ आप
AndroidManifest.xml <receiver> element क define क क क
<receiver> element क android:name attribute आप BroadcastRecevier क extend क न
क न
क आप <receiver> ए क <intent-filter> element क औ क sub
element <action> intent क न क ए आपक broadcast receiver register
क न
Example
<receiver android:name=".yourClassName">
<intent-filter>
<action android:name="Name of intent that you want to listen">
</intent-filter>
</receiver>
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 8
Intents
This chapter covers
 Introduction
 Types of intents
 Intent filters
Introduction to android intents
Intents क आप क न .
क
 contacts list न .
 क क क न
 messages क न
आप क न आप ए क क एक क .
Intents messages android components(Activity, Service, Broadcast receiver,
Content provider ) एक क . एक component क component क क
functionality क ए request क . request messages क क intents क
. Intents asynchronous messages क android components एक messages क
क .
Intents क आप same ए क न कप न क क क औ
ए क न क कप न आप intents क क क . क ए क ई activity
activity क क क क contacts क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
android.content.Intent android system क आप ऑ ए क औ न
ऑ आप क न (ACTION) औ आपक क प न (URI of Target
Component) आप आ क प क .
आपक Activity क क न प आप Android in Hindi : Activity tutorial
क . क activity क क न क ए प आपक intent ए क न क
आप startActivity() क क क intent क आ क प क एक ए
ए
Example
Intent contactsIntent = new
Intent(Intent.ACTION_PICK,Uri.parse("Content://contacts/people"));
startActivity(contactsIntent);
example प न एक intent ए क न न contactsIntent. Intent ए
क न क क क न . क न न क क
क न . क न startActivity() क क न
क प क . एक ए क क क क क .
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Services क नन क ए आप Android in Hindi : Services क . न
एक ए क क आप एक Service क क . क ए आपक
startService() क क क प क न
Example
Intent contactsIntent = new
Intent(Intent.ACTION_PICK,Uri.parse("Content://contacts/people"));
startService (contactsIntent);
Broadcast messages android system . एक broadcast
receiver ऐ messages क ए register क क . generate
notification message .
Types of intents
Intents 2 क Implicit intent औ Explicit intent.
Implicit intent
क आपन एक intent ए क क एक ए क ओपन क . कन android system
एक browsers क . एक target (Browser ) directly open
न न browsers नक ए क क औ
क intent execute
Explicit intent
Explicit intents आप प न क क intent क क ए न .
क आपन एक intent ए क एक ए ओपन क आप प न क
क Google Chrome क execute न . क प न प न
क .
Intent filters
आपन एक application ए क क एक browser . क pdf reader क ए
क क प क क एक generate . आप क आपक
ए ओपन आपक intent intent filter पन application क component क ए
declare क न
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
क ई intent generate registered ए क न कप न क message
औ क according ए न . आप क आपक ए क न intents क receive क
क आपक पन ए क न क intent क ए register क न Intents क ए register
क न क ए आपक intent-filter क न .
आपक AndroidManifest.xml क नन आप Android in Hindi :
AndroidManifest.xml file tutorial क .
intent filters आप AndroidManifest.xml ए क .
Example
<intent-filter>
</intent-filter>
Intent filters क 3 element tags .
 <action > - आप न क क आप क क action क ए intent filter
न क . एक ए क न कई intents generate क क . कन आप नक
ए न क आ प प न क . Action न क न क ए andorid : name
attribute क .
 <data > - आप न क क आप क क क ए intent filter न
क . basically components क URI . क define क न क ए android :
scheme attribute क .
 <category > - आप intent क category define क . आप default-category
क क . Category न क न क ए android : name attribute क
.
ए न आप intent ए क न क action आप action . औ
आप Component क URI .
Explicit intents target component न क . कन implicit intents target
component न न . ए न application क implicit intents receive क न
intent filters क . intent ए notification message
.
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 9
Views
This chapter covers
 Introduction
 Different Android views
 Common methods
Introduction to android views
Android views ए क Android views elements न प
, क button, text-box आ views activity क
Android view classes, views क represent क android view एक view class क
represent क क button क represent क न क ए Button class provide क
न classes क events क user interact क
Android views क form represent क activity views hierarchical tree क form
represent क views क size न
views क android platform include क
आप क android views create क क
Android platform included views क आप क views create क क आप views
क directly code क XML file आप क क
Common android views
आप क single ए क view क views क एक क
layout क show क view-group क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
View's
View class क Analog-Clock, Progress-Bar, Image-View, Surface-View, View-Group, Text-
View औ View-Stub classes extend क
Text-View - Text-View view क extend क Text-View क Edit-Text,
Digital-Clock, Chronometer, Checked-Text-View औ Button classes extend क
Button class क Compound-Button class extend क Compound-Button class क Radio-
Button औ Check-Box Classes extend क
Image-View - Image-View class क Image-Button class extend क class image
buttons ए क न क ए क
Surface-View - Video-View Surface-View class क extend क screen प
video क न क ए क
Analog-Clock - class screen प analog clock ए क न क ए क
Progress-Bar - क process क ए progress bar ए क न क ए क
View-Stub - views क ए layout ए क न क ए क
View-Group's
View-Group View क ए क View-Group क Map-View, Adapter-
View, Relative-Layout, Linear-Layout, Frame-Layout औ Absolute-Layout extend
क
Map-View - क screen प प क क क
Adapter-View - Spinner, Grid-View, Gallery औ List-View classes Adapter-View क
extend क
Relative-Layout - क Dial-er-Filter औ Two-Line-List-Item ए क
classes views क ए relative layout provide क
Linear-Layout - Table-Layout, Table-Row, Radio-Group, Tab-Widget, Zoom-Controls
Linear-Layout क extend क views क ए Linear layout
क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Frame-Layout - Scroll-View, Time-Picker, Date-Picker, Ticker, Scale-Layout, View-
Animator Frame-Layout क extend क views क ए frame layout
क
Absolute-Layout - क Web-View extend क views क ए
Absolute-Layout provide क
Common methods used with android views
 set-Background-Color(int Color) - background color set क न क ए क
 set-Background-Draw-able(Draw-able d ) - एक draw-able background
क न क ए क क क ई image आप background क क
 set-Clickable(Boolean c) - आप element प आप क क
clickable न क
 set-Focus-able(Boolean f ) - आप ए क focus-able न क
 set-Layout-Pa-rams(View-Group.Layout-Pa-rams l ) - क आप आ क
position औ size क क
 set-Minimum-Height(int min-Height) - आप ए क minimum height
क क
 set-Minimum-Width(int min-Width) - आप element क minimum width क
क
 set-On-Click-Listener(on-Click-Listener l) - आप एक listener क क
क events generate न प respond क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 10
Fragments
This chapter covers
 Introduction
 Life cycle of fragments
 Types of fragments
 Creating android fragments
Introduction to android fragments
एक fragment क activity क एक separate UI (user interface) Fragments क
क life cycle औ input events आप एक fragment क कई activities क क
आपक activity running state आप fragments क add औ remove क क
Fragments क आप sub activity क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Android fragments क android क Honeycomb version introduce क Android
fragments प आप user क एक एक activity क क ए आप न क
parts divide न क क
Fragments क आन application design औ flexible क आप क एक
एक interface क क औ separately manage क क आपक
प activity एक कन आप fragments add क क
एक fragment activity embedded न ए Fragments क life cycle activity क life
cycle directly affected क ए activity pause क
fragments pause activity destroy ए क fragments destroy
activity running state आप क fragments क independently manage क
क
आप fragment क ऐ क fragment आपक activity क view hierarchy क View-Group
, औ क view layout न क आप fragment क activity layout क
क ए आपक activity layout file <fragment> क क न
क क fragment क activity layout क प न न क क ई आ क न आप
fragments क न UI क ए क क क प प पन क क क
Basically fragments क tablet devices क ए design क , क tablet devices
प space क आप fragments क आ न क क Activity क
layout क fragments divide क क आप screen क appearance क क क
क ए आप एक fragment screen क left side links क list provide क क , औ
right side क fragment न articles क open क क
आपक fragments क design क न ए क एक fragment कई activities क
क fragment क क layout औ क life cycle ए आपक fragments
क ऐ design क न ए क एक fragment क आप कई activities क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
ऐ क न ए आ क क आप fragments क different screen sizes क क
आप पन application क tablet औ handset न devices क ए न आप fragment क
configure क क क न devices प आ न न क
Fragments life cycle
Creating Fragments
Fragment create क न क ए आपक Fragment क extend क न Fragment
Activity क आप प ए क activity life cycle औ fragment life cycle
ऑ same
आपक life cycle methods क implement क न क आ क न , कन आपक
onCreate(), onCreateView() औ onPause() methods क क न ए
Fragment क 3 important sub class’s आप ए क क -
 DialogFragment - एक floating dialog ए क न क ए क क
Dialog ए क न क ए क क न एक alternative
 ListFragment - एक items क display क आप adapter manage
क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
 PreferenceFragment - preference ऑ क hierarchy क एक क
क
Declaring fragments in layout file
Fragments क layout file declare क न क ए आपक <fragment> element क न
element क एक important attribute android:name, आप क न प
क fragment क extend क
<fragment> element android:id attribute , आप एक नक id प क
Example
<fragment android:name="class name which extends Fragment class" android:id="ïd">
</fragment>
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 11
Layouts
This chapter covers
 Introduction
 Attributes of layouts
 Types of layouts
Introduction to android layouts
क न आपक प आप views ए क order
आपन ए क एक क कई ऐ क क आप क view क screen प
एक particular position प place क न ऐ आप android layouts क क क
Layouts क ए structure क structure क according आप पन
elements न प न क क Android system कई क layouts provide क
आपक ए क न क ए layout आपक क आप क क
Android layouts आप 2 define क क आप एक XML क ऐ क
क run time view औ view groups क objects ए क क ऐ क क
आप क पन क आप न क पन क आप XML क
ए क ए layouts क run time क क आप layouts XML क
क आप पन ए क न क view क औ ए क न क behavior क
control क क
Attributes of android layouts
न क common attributes ए views क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
 android:id - attribute क आप view क id define क view क uniquely
identify क न क क आ
 android:layout_width - attribute क आप view क screen प width define क
 android:layout_height - attribute क आप view क न प height define क
Types of android layouts
Linear layout
Linear layout एक ऐ layout elements एक direction vertical
horizontal. आप layout क direction android:orientation attribute क define क क
layout क direction vertical एक column एक ए आए औ layout क
direction horizontal एक row एक element आए
आप क एक particular element क priority क layout weight
क ऐ आप android:layout_weight attribute न क क क क element क
न weight न space screen प cover क
क element क weight क elements क elements क set न क
remaining space element cover क
Linear layout ए क न क ए आपक XML file <LinearLayout> element declare क न
element क android:layout_width, android:layout_height औ android:orientation 3
attributes न न attributes क ए values provide क क आप layout क set क क
Example
<LinearLayout xmlns:android="android schema address"
android:layout_width="width of layout"
android:layout_height="height of layout"
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
android:orientation="layout orientation">
<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:text="name of button" />
<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:text="name of button" />
</LinearLayout>
Relative layout
Relative layout view elements क relative positions प display क view क आप
elements क relation position क क क नए view क position आप existing view क
relation define क क आप existing element क right नए element क set क न
left क आप क element क screen प क place क क
Relative layout views क position क न क ए क attributes provide क , नक आप
पन view क position क क आ न attributes क नन क क -
android:layout_alignParentTop
क view element attribute क value true view आप क न top प
android:layout_centralVertical
क view element attribute क view आप क न vertically center
android:layout_below
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
attribute आपक view element क view क न position क आपन resource id क
define क
android:layout_toRightOf
attribute आपक view element क view element क right place क आपन resource
id क define क
प क ए ए attributes आप पन आ क क न
क क
Example
<RelativeLayout xmlns:android="android schema address"
android:layout_width="width of layout"
android:layout_height="height of layout"
android:paddingLeft="in dp"
android:paddingRight="in dp">
<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:layout_below="id of other view element"
andorid:text="name of button" />
<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:layout_centralVertical="id of other view element"
android:text="name of button" />
</RelativeLayout>
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
ListView
ListView एक view group items क list क आप scroll क क layout
run time views क न क क layout एक column औ row
न आप एक row एक view position क क
Run time आप adapter क क array database item क pull क adapter
item क view convert क क list क आ add क
GridView
GridView एक view group items क two dimensional grid क grid क आप
scroll क क layout items rows औ columns क form GridView
items run time प automatically insert
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 12
Resources
This chapter covers
 Introduction
 Alternative resources
 Supplying resources
 Retreiving resources
 Types of resources
Introduction to android resources
क न आपक प resources files आपक ए क न code include
क Resources क application क code separately maintain क Resources क
ए क न separate क न आप resources क independently maintain क क
Resources क आपक ए क न directory क /res folder maintain क Android studio
/res folder क position न window
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
/res क sub directories औ न maintain क न resource types क न
Alternative resources
devices क configuration क tablet device क screen
size mobile device ए application क device configuration क
support क न क ए alternative resources क न ए
आपक ए क न run android device configuration क detect क औ
device क according resources load क
Alternative resources न क न क ए आपक /res <resources-name>-
<config_qualifier> directory ए क न
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 13
Diaglogs
This chapter covers
 Introduction
 Creating dialogs
 Adding buttons
 Adding lists
Introduction to android dialogs
Dialog एक window क ई decision क क information input
क क Dialog प screen क cover न क
Android dialogs 3 क -
 Alert dialog - एक simple alert dialog क dialog आप title क क
, 3 न add क क औ items क list क क select क क
dialog ए क न क ए आपक AlertDialog क extend क न प
 Date picker dialog - क dialog आप क एक window क क
date select क क क dialog ए क न क ए आपक
DatePickerDialog क extend क न
 Time picker dialog - क dialog time select क क क
dialog ए क न क ए आपक TimePickerDialog क extend क न
classes Dialog क extend क न dialog क क न प आपक
पन dialog क ए एक container ए क न क ए आप DialogFragment क
extend क क DialogFragment dialog create क न औ क न क न क ए
methods क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Creating android dialogs
Android dialogs ए क न आ न क ए आपक 2 3 statements न
Example
AlertDialog.Builder yrobj = new AlertDialog.Builder(getActivity()); //creating alert dialog
yrobj.setMessage(R.string.yrmessage); //setting message
yrobj.setTitle(R.string.yrtitle); // setting title
AlertDialog ad = yrobj.create(); // getting alert dialog from AlertDialog.Builder
Dialog ए क न प आपक dialog fragment ए क न क ए आप
DialogFragment क extend क आप onCreateDialog() क
implement क औ आप dialog ए क Dialog ए क न क ए आप
Builder क क
Example
public class yrclass extends DialogFragment
{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
// create yr dialog here as shown above
}
}
आप क object प show() क क dialog
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Adding buttons to android dialogs
Android alert dialogs आप 3 क buttons add क क -
 Positive button - button positive response क ए क क ok
yes क न create क न क ए आपक setPositiveButton() method क call
क न क आप alert dialog क object प क क 2
arguments प एक button क न औ DialogInterface क object
interface onClickListener() provide क क आप implement क
 Negative button - button negative response क ए क क no
cancel क button dialog add क न क ए आपक alert dialog क ऑ प
setNegativeButton() call क न
 Neutral button - एक simple button आप क ई action क
क button क simply android button create क create क
Example
DialogInterface.onClickListerner di = new DialogInterface.onClickListener(); // creating dialog
interface object for event handling
yrobj.setPositiveButton(R.string.button-name, di); // setting positive button
public void onClick(DialogInterface di, int id)
{
//handle on click event here
}
आप negative button ए क क
Adding lists to android dialogs
Android alert dialogs आप 3 क list add क क -
 Single choice list - क list क ई एक item select क क Item
select प event generate औ code क according action
 Single choice radio list - क क list radio buttons क show क
User क ई एक select क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
 Multiple choice check-box list - क list एक कई items select क
क क list checkboxes क show
Alert dialogs ए क न क ए आपक setItems() method क क न method
2 arguments प क एक list items क array औ
DialogInterface.onClickListener interface क object क न ऊप button add क न क ए
क
DialogInterface.onClickListener क onClick क implement क क आप select
event क क क ऊप setPositiveButton() method क आपन क आ
setItems क structure -
yrobj.setItems(R.Array.yrarray, DialogInterface.onClickListener di);
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 14
Notifications
This chapter covers
 Introduction
 Contents of android notification
 Creating notifications
 Taking action
Introduction to android notifications
Notifications आपक device top प battery औ signal icons क प आपन
आपक device प क ई mail text message आ top प एक message icon
messages notifications क
क ई notification आ प क icon क क ई mail आ
Gmail क icon क notification क detail नन
notification drawer क open क
devices notification drawer top bottom क swipe क open
Notification drawer क क क क settings
क WiFi, Bluetooth, screen brightness आ
आप notification क क ई action क क notification प
click क आपक application open actions क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Contents of android notification
 Icon - एक icon notification related ए क न क represent क
 Title - notification क title notification क purpose क
 Detail text - detailed text message
Creating a notification
एक notification ए क न क ए प आप NotificationCompat.Builder क object
ए क एक public static आ न notifications ए क न क ए एक
builder आप current activity क reference प क
क आप builder क object क notification क contents क Icon set
क न क ए setSmallIcon() method क क औ icon क ए प क Notification क
title क न क ए आप setContentTitle() method क क औ title string प क
Detailed message set क न क ए setContentText() method क क औ text string
प क
क आप NotificationCompat.Builder क object प build() method क क
method एक notification return क notification method return क
contents क loaded आपन set क
आ notification क issue क न क ए आप build method न notification object
return क notify() प क क NotificationManager क object
प क क
Example
NotificationCompat.Builder ncb = new NotificationCompat.Builder(this); // crating builder
class object
ncb.setSmallIcon(R.drawable.yricon); // setting icon
ncb.setContentTitle("your notification title"); //setting title
ncb.setContextText("your notification message");// setting text
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Notification noti = ncb.build(); //creating notification
NotificationManager nm = new NotificationManager();
nm.notify(noti); //showing notification
Taking actions with notifications
Android notifications क action न optional आप एक simple text message क
क notification प क क क ई notification क क action क
आप notification drawer क पन ए क न क
Notification क आप कई क क action क आप notification button
provide क क press क न प आपक application न open ए क ए न perform
क
notification प click क application क open क न common ए न
action क ए आप builder क object प setContentIntent() क क औ
PendingIntent क ऑ प क PendingIntent क object ए क
आप normal intent क object प क intent application क open क न क action क
define क
Example
Intent yrIntent = new Intent(this,yrActivity.class);
pendingIntent pi = new pendingIntent(yrIntent);
ncb.setContentIntent(pi);
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 15
Menus
This chapter covers
 Introduction
 Creating a menu in XML
 Options menu
 Context menu
 Popup menu
Introduction to android menus
Menus क ए क न क एक क न क easy औ designer
क न क ए आप menus क क क Menus क आप न ए ए 3
reasons क क क
 User क application क components क link provide क न क ए
 Application क structure क न क ए
 navigation क ए
Android menus 3 क -
1. Options menus
2. Context menus
3. Popup menus
Creating a menu in XML layout file
menu types क ए menu items न क न क ए android एक XML format
क पन activity क क menu ए क न क ए आप आप एक XML
layout file menus न क आप पन activity load क क ऐ XML
layout file क menu resource क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
क ए प आपक पन क res/menu directory एक XML ए क न
XML file menu ए क न क ए आप क elements क क आ न ए क
नन क क
<menu> - ए menu define क element menu items क base क क क
आपक file प ए declare न ए क आप <item> औ <group>
ए क
<item> - ए एक menu item ए क item क ए आपक एक item element
declare क न <item> element क attributes क क न ए
android : id - एक नक id android system menu item क uniquely identify क
android : icon - attribute क आप क image क item क icon क क क
android : title - attribute आप item क title declare क
<group> - element container क , कन एक menu items क एक
न क ए क
Example
<menu xmlns:android="schema address">
<item andorid:id="1" android:icon="address of icon image" android:title="First Item">
<item andorid:id="2" android:icon="address of icon image" android:title="Second Item">
<item andorid:id="3" android:icon="address of icon image" android:title="Third Item">
</menu>
Options menus
क application क ए options menus primary menus Options menu आपक
options न ए प application क control क क औ क option आप
options menus क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
आप android gingerbread lower versions क ए ए क न develop क
न न प क क क menus क क
आप android honeycomb ऊप क versions क ए options menus develop क
app bar क menus क access क क
Creating options menus
Options menu क ए items आप activity subclass fragment subclass क
क आप न क items क interface न combine
Activity क item प क order fragments क ऐ क आ
नक items आप menu items क reorder क क
क activity options न define क न क ए आपक onCreateOptionsMenu() क
override क न क न
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// put menu resources in menu from XML
}
क आप न resources क न क आप आप add() क
items क add क क औ न items क न क ए आप findItem() क
क
Context menus
एक context menu option क क एक ए क effect क . ए
न long click क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Context menus movable menus क क ए प क क
menu element क effect क न ऑ न क प न
long क क
आप android honeycomb higher versions क ए ए क न develop क selected
elements प ए न प क न क ए आपक contextual action mode क न ए
आप क view क ए context menu क क कन view groups क
ए क क view groups elements प direct actions प क क
Creating context menus
Context menu ए क न क ए प आपक view क ए आप context menu ए
क न क register क न क ए आपक registerForContextMenu() क
क न औ view प क न
क आपक onCreateContextMenu() क ओ क न registered
view प long क क system क क क आप menu items
define क क न -
@Override
public void onCreateContextMenu(ContextMenu contextmenu, View view, ContextMenuInfo
contextmenuinfo)
{
// declare menu items and put menu resources
}
क आपक onContextItemSelected() क ओ क न क ई न
क ई item select क system क क क आप item select न प task
complete क न क क क न
@Override
public boolean onContextItemSelected(MenuItem item)
{
// perform desired task
}
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
getItemId() आप selected item क id प क औ item प action क
Popup menus
एक popup menu items क vertical list क Pop menus anchor view क
available anchor view क न न anchor view क ऊप
Popup menus ऐ options क same activity views क perform क
क
Creating popup menu
आप menu क XML क define क न ऐ आप क क -
प आपक PopupMenu क एक object ए क न Object ए क
आप current application क context औ view pass क आप popup menu न
क PopupMenu.getMenu() क क क आप क Menu क reference न औ
MenuInflater क न resources put क न
आ menu क क न क ए PopupMenu.show() method क क न
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 16
Buttons
This chapter covers
 Introduction
 Steps to create buttons
 Creating buttons
 Designing buttons
Introduction to android buttons
Buttons क ए क न क ए important element Button क click क न प
button क ई action perform क क ए आपक button क coding क न
button क एक न Android buttons क ए आप न क क ई icon क क
Android buttons क एक न क औ icon
Android buttons editable Android buttons क styling न क क ए आप
different styles औ themes क क
Button प click onClick event occur event क handle क न क ए coding
क
Steps to create android buttons
प आप activity_main.xml file button add क
क आप MainActivity.java file button क click event क coding क coding आप 2
क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Creating android buttons
Adding button to XML file
Button क XML file ए क क ए आप <Button> element
क <Button> ए क क attributes , न ए
Android : layout_width - attribute क आप button क width set क क
Android : layout_height - attribute आप button क height क
Android : text = "string" - attribute क आप button क न
Android : src = "@drawable/button_icon" - attribute क आप button क icon क क
Example
<Button
Android:layout_width="width of button"
Android:layout_height="height of button"
Android:text="name of button"
Android:src="icon of button" />
Handling onClick event
onClick event आप 2 handle क क प क आप <Button> element क
android:onClick attribute क क आप activity class एक method ए क
method button क क न प क method क न आप android:onClick
attribute प क
Example
In XML file
<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:text="name of button"
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
android:onClick="yourMethod" />
In your activity class
public void yourMethod(View view)
{
// perform your task here
}
button प click क onClick attribute define क आ method क
क आप XML न क क run time events handle क न क ए प
क आप एक button object ए क औ button object प
setOnClickListener() क क औ onClickListener क
आप run time event handle क न क क क XML file क
button ए क न easy
Designing android buttons
devices styles क ए आपक buttons devices प
styles आप पन buttons क style क control क क क ए आप
प ए क न प एक theme apply क
Android आपक android:theme attribute provide क attribute क आप <application>
element apply क element AndroidManifest.xml declared
आप buttons क individually configure क न आप android:background attribute
क क attribute आप क ई image प क क औ क ई क प क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 17
Text fields
This chapter covers
 Introduction
 Creating text fields
 Input types
 Keyboard actions
Introduction to android text fields
आप पन android application text fields ए क क Text fields क text boxes क
एक text field क आप input क क न औ ई ए
text fields एक न क कन आप android multiple lines क text
ए क क
Text ए क न क ए text field प क क क क क न प typing cursor text
field प क न क ए keyboard automatically
आप text fields क क input values क ए configure क क क क
text box क आप email क ए configure क क Android text fields क ए आप actions
define क क input क न क perform क
Creating android text fields
Text fields आप पन layout add क क क ए आप XML layout file <EditText>
element define क <EditText> element क basic attributes view elements
define क -
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
 android:id - attribute text field क id define क
 android:layout_width - attribute text field क width define क
 android:layout_height - ए क आप text field क height define क
 android:hint - attribute क आप input type क hint क
 android:inputType - attribute क आप input type न क
 android:imeOptions - attribute क आप action define क
Example
<EditText
android:id="id for text field"
android:layout_width="width of text field"
android:layout_height="height of text field"
android:hint="hint of input type"
android:inputType="input type"
android:imeOptions="action" />
Input types of android text fields
Text fields क values क क text, number, date औ email
address. एक text field आप क क enter क क आप android:inputType
attribute क न क
attribute क ए common input types न ए input types
keyboard क
 text - input type text enter क न क ए declare क normal text
क क
 textEmailAddress - input type email address नप क न क ए क
normal keyboard @ sign क
 textUri - नप प आप text field URL enter क क input type
text keyboard क / क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
 number - input type numbers ए क न क ए क औ numbers क
keyboard क
 phone - input type क phone style keyboard क ए क

Example
<EditText
android:id="id for text field"
android:layout_width="width of text field"
android:layout_height="height of text field"
android:hint="hint of input type"
android:inputType="textEmailAddress"
android:imeOptions="action" />
Keyboard actions of android text fields
User क information input क न क action action आपक
ए क न प depend क क आपक ए क न searching क service provide क
action search क औ आपक ए क न messaging क service provide क
action send क
क क action आप न आपक application प न आप क ई action
न न क next क option न right hand side corner न action
आप न क
Keyboard action आप android:imeOptions attribute क न क क
Example
<EditText android:id="id for text field"
android:layout_width="width of text field"
android:layout_height="height of text field"
android:hint="hint of input type"
android:inputType="textEmailAddress"
android:imeOptions="actionSend" />
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 18
Spinners
This chapter covers
 Introduction
 Defining spinners
 Creating spinners
 Responding to selections
Introduction to android spinners
Android spinners आपक ए क न एक drop down menu drop down menu
items user choices क user spinner प क क items
पन ए appropriate choice choose क By default spinner top
element
Spinners क XML layout file ए क औ items क string resource file
ए क आप एक string array ए क
Spinner औ items क न क ए एक array adapter ए क क selection
events क respond क न क ए OnItemSelectedListener interface क क
Defining android spinners
Android spinners क आप XML layout file define क क ए आप <Spinner> element
define क element क basic attribute view elements
 android:id - attribute क आप spinner क id define क
 android:layout_width - attribute क आप spinner क width define क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
 android:layout_height - attribute क आप spinner क height न क
Example
<Spinner
android:id="@+id/yrspinnerid"
android:layout_width="width-of-spinner"
android:layout_height="height-of-spinner" />
Creating spinner items list
Spinners क items list एक string resource file आप ए क क क ए आप एक string
array ए क क ए आप <resources> element क <resources> element क
आप <string-array> sub-element define क
<string-array> element क name attribute आप array क न define क क <string-
array> element <item> sub element define क औ items क आप element define
क
Example
<resources>
<string-array name="yrstringarray">
<item>Item 1</item>
<item>Item 2</item>
<item>Item 3</item>
</string-array>
</resources>
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Items क ए क न क array औ spinner क connect क न क ए आप एक array
adapter ए क
क ए प आप एक spinner object create क औ क reference XML layout file
आपन spinner define क क ऐ आप spinner क id क क
Example
Spinner yrspinner = (Spinner) findViewById(R.id.yrspinnerid);
क आप ArrayAdapter क object create क
Example
ArrayAdapter<CharSequence> yrAdapter = new ArrayAdapter();
क string resource file आप ArrayAdapter directly ए न क क क ए आप
ArrayAdapter क object प createFromResource() method क क आप current
context, string array औ items क layout प क
Example
yrAdapter.createFromResource(this,R.array.yrstringarray,android.R.layout.simple_spinner_it
em);
क layout आप items display क क न set क क ए आप
adapter object प setDropDownViewResource() method call औ layout आप
क न pass क
Example
yrAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
क आप adapter क spinner क apply क
Example
yrspinner.setAdapter(yrAdapter);
क आप क क ई item select क न प action न define क
Responding to item selection
क ई item select क ऐ situation आप क action न action आप
onItemSelected() method न क method क आप Activity क inherit क न
न क onItemSelectedListener interface क implement
क न ए
method आप AndroidView, View, position औ spinner क id प क
Example
public void onItemSelected (AdapterView av, View view, int posi, long id )
{
// handle what you want to do here
}
आप क select न क ऐ situation आप क ई action क क
ए आपक onNothingSelected() method क define क न
Example
public void onNothingSelected(AdapterView av)
{
// handle what you want to do here
}
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 19
Search Interface
This chapter covers
 Introduction
 Creating search interface
 Adding custom suggestions
Introduction to android search interface
Searching क ए क न क एक important feature क आप क
आपक application क particular information service क ए search क क आपक क
ए पन ए क न search interface add क न
Android applications आप search interface 2 add क क एक आप पन
application क top area search dialog add क क क आप एक search widget
क पन application embed क क
Android system search interface implement क न आपक क search queries क
ऐ activity क प searching perform क आप search क आप
suggestions provide क क
Android क search framework आपक application data search क न क ए API
provide न क आपक पन application क एक API choose क न
Creating android search interface
क न आपक प android search interface आप 2 implement क क
प आप एक search dialog implement क क औ आप search widget क embed
क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
न situation search query आपक application क क specific activity क प
आ प न न क क न
Search dialog एक UI (User Interface) component user search option प click
क activate औ search dialog क आप ऊप ई picture
क Searches क handle क न क ए आपक एक activity specify क न
query submit क query activity क प आपन specify क
Search widget क आप layout क क Search widget SearchView क
object search widget एक text box क कन आप configure
क क क queries एक particular activity क deliver क क
query submit क android system us query क intent save क औ
intent क आपक application क activity क आपन searches handle क न
क ए specify क
पन application searching capability add क न क ए आपक 3 क प
 प एक XML file क आप search dialog क settings क configure
क
 क आप एक activity create क user क queries क handle क
 क आपक एक search interface क आ क क UI provide क
आ न steps क detail -
XML file
एक XML file आप <searchable> element declare क <searchable>
element क एक attribute android : label आप application क name specify क
file क आप क ई न क कन क most common न searchable
Example
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="application_name">
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
</searchable>
Activity to handle searches
Searches क handle क न activity एक ऐ activity user क queries क handle
क औ results क search queries intent क activity क प
क क intent क action ACTION_SEARCH
Android system क ए क android system searches क handle क न activity क
identify क क ए आपक activity क AndroidManifest.xml file define क न
क न -
Example
<activity android:name=".your_search_handler_activity">
<intent-filter>
<action android:name="android.intent.action.SEARCH">
</intent-filter>
<meta-data android:name="android.app.searchable" android:resource="@xml/ your
configuration file with searchable element">
</activity>
ऊप ए 2 important एक क <intent-filter> element क android:action
attribute action SEARCH define क
<meta-data> element क android:name attribute आप android.app.searchable
औ android:resource attribute configuration XML file क URL आपन
<searchable> element declare क
आप searches क handle क न activity onCreate() method क override क क
getIntent() intent क क औ intent क compare क क search action
intent
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
क intent search action आप query क extract क औ एक
query क न variable create क क store क Intent query extract क न क
ए आप getStringExtra() क
एक आप query extract क query क न प आपक पन application data
search क न औ result क न Data search क न application
क क
आपक data SQLite database आप आ न android.database.sqlite API क
ए search क क औ आपक data online stored user क data connection
wifi क आ क
Search results क ListView क न क आप setListAdapter क
data adapter क bound क क औ results क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 20
Android file system
This chapter covers
 Introduction
 Core directories of android file system
 Sharing files
Introduction to android file system
Android file system न directories आ न क purpose न
क directories ऐ नक न android system क न क क Android क
file system device related data औ user क data User क files
core file system क corrupt न क क ए user files औ system files क
directories क
Android system files क unauthorized access न क permissions provide क
क ऐ device run क न क ए necessary ऐ files क आप delete
न क क ए ऐ files क ए read permission User files क ए
complete permission आप read क क औ file क modify क क औ
delete क क
Android file system एक hierarchy क represent क Android file system
directories कन न क आपक न क न क necessary directories नक
आपक ऊ
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Directories of android file system
/Boot - directory tools available android system क start न क ए
necessary directory kernel औ ram-disk directory क न आपक
device start न क directory क delete क आपक device क
start न क क आप प न
/System - directory आपक प android operating system directory
android क graphical user interface application आपक device प
installed क ई आ directory directory क delete क
आपक phone on कन android operating system न ए आप device
क न क क
/Recovery - directory backup क ए न आपक system क boot directory
corrupt आपक प एक क प directory क आप pure system क
recover क क
/Data - directory क data store क directory user क images, files,
videos औ contacts User android applications install क directory
store क आप पन devices क reset क directory प
/Cache - directory files औ applications आप frequently क
directory क format क न user औ system data प क ई क न प directory क
format क क आप RAM memory क क
/Misc - directory क settings store क device क personalize क
Sharing files
कई एक application application क files share क न क आ क
क ए आप पन क क क ई picture न picture gallery application
whats-app application क picture क आप पन application क क
file क क क File क एक application application क प न क ए आपक
पन application क configure क न आप files क content URI क form क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Android FileProvider class content URI generate क क application क files
क न क क क आप files क send न क क नक URI (files URL ) क
क औ application क क क ए file क access क न क permission
Send क न files क URL क न safe आप receive क न application
क uniquely identify क क औ application क औ क ई application files क
access न क क Content URI क पन आप expire
FileProvider क getUriForFile() method क file क URI generate क न क ए
क method आप file क न argument क प क औ function आपक
file क URI return क
Files क न क ए आपक पन application FileProvider क define क न ऐ आप
FileProvider क entry AndroidManifest.xml file क क क क क ए आप <provider>
element क element क 4 attributes -
 andriod:name - आप FileProvider क URI
 android:authorities - आप authority क न आप FileProvider क
generated content URI क ए क न ex. yrPackage.fileprovider.
 android:grantUriPermission - attribute क आप set क
 android:exported - attribute क आप initially false set क
Ex.
<provider android:name="URI-of-file-provider-URI" android:authorities="name-Of-Authority"
android:grantUriPermission="true" android:exported="false">
<meta-data> element <provider> element क एक sub element element एक XML file
क define क आप क न क न directories share क न
element क 2 attributes -
 android:name - आप FileProvider क paths क URI
 android:resource - आप XML file क URI
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Ex.
<meta-data android:name="file-provider-paths-URI" resource="name-of-XML-file" >
XML file directories आप share क न define क न क आ न क
ए आप <paths> element क element क एक sub element <files-path>.
element आप directory क path element क 2 attribute name औ path.
Ex.
<paths>
<files-path path ="yourDirectory/" name="nameOfFile">
</paths>
आप पन class क ए file provider define क applications आन requests
क आप handle क क ऐ क न क एक क क आप एक activity create क file
selection interface provide क औ files select क ए आप selection प action
क कन action न प आपक application क access permissions न ए
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
Chapter 21
Storage system
This chapter covers
 Introduction
 Storage options
o Shared preferences
o Internal storage
o External storage
Introduction to Android storage system
Android system क क न क ए options provide क आप क न option
choose क आप प depend क आपक data primitive आप shared
preferences क क आपक data private आप internal storage store क
क आपक application क ए database store क न आप SQLite
database क क औ आप network connection क क cloud
storage पन data क क
क android system न storage option provide क कन पन application
क ए storage option choose क न necessary क ए आपक पन project
ए members क advice न ए
आ different android storage options क detail नन क क
Shared preferences
SharedPreferences एक आपक एक provide क आप
key value क pair क primitive values (int , boolean, char, float, strings) store क क
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
आप shared preferences store क different user sessions available
SharedPreferences क object क न क ए आपक प 2 options एक आप
getSharedPreferences() method क क क method आपक क न ए
आप preferences files ए क न option क आप getPreferences()
क क method क आप एक preference file ए क क
प आप SharedPreferences क object ए क आप variable क न औ
initial value प क
SharedPreferences myObj = new SharedPreferences(variable_name, initial-value);
SharedPreferences क object ए क न क value store क न क ए आपक
SharedPreferences.Editor क ऑ ए क न ऐ आप SharedPreferences
क object प edit() क क क क क
SharedPreferences.Editor ediObj = myObj.edit();
क values store क न क ए methods क putBoolean() औ
putString() आ न methods क आप editor object प क क
ediObj.putString("name",value);
क आपक values क commit क न
ediObj.commit();
Values क read क न क ए आप SharedPreferences क ऑ प methods
क क क क getBoolean() औ getString() आ
Internal storage
आप files क device क internal memory save क क files internal memory
saved private , applications access न क क आपक
application क remove क files remove
क file क internal storage save क न क ए आपक openFileOutput() method क क न
method FileOutputStream class क object return क FileOutputStream
data क file क through output क न क ए क एक stream क represent
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
क openFileOutput() आप file क न औ mode pass क File क 4 mode
क
 MODE_PRIVATE - default mode mode file private
 MODE_APPEND - प क ए न क file प न file क data क
आ add
 MODE_WORLD_READABLE - क files create क न security क point of view
risky क क क ई application access क क
 MODE_WORLD_WRITABLE - क file क क ई application modify क
क
FileOutputStream क object प न क आप प write() क क औ file क save क
क आप close method call क क output stream close क
Ex.
String name="yrName";
FileOutputStream obj = openFileOutput(fileName,Context.MODE_PRIVATE);
obj.write(name.getBytes()); // write data in form of byte only.
obj.close(); // closing stream
क internal storage files क read क न क ए आपक openFileInput() method क
क न method FileInputStream क object return क method आप file क
न प क क आप FileInputStream क object प read() क क क file क read
क
Ex.
FileInputStream obj = openFileInput(fileName);
obj.read();
obj.close();
External storage
android device capability क आप external memory add क क
memory removable क क SD card आ औ non removable क कई
internal memory क limit क क external memory क क External
©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com
storage save न classes world readable mode क औ आप पन
device क PC connect क न files क क ई modify क क
आपक application external storage files save क न क ए क 2 क
system permissions क आ क
 READ_EXTERNAL_STORAGE - permission external storage files क read क न
क ए
 WRITE_EXTERNAL_STORAGE - permission external storage files save क न क
ए
Ex.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
External storage क ई क क न प आपक memory क media status क क न
ए क क external storage क ई file न readable files External
storage क status check क न क ए आप getExternalStorageState() method क क क
method आपक files क states return क न आप क notify क क
आप files क public न आप public directories save क क क
Music, Pictures आ External storage files save क न आ न क ए आप एक
file ऑ ए क औ file क न औ public directory क न प क
Ex.
File myFile = newFile(DIRECTORY_PUBLIC, fileName);
External storage save क files क आप internal storage क files क न
methods open औ edit क क

Contenu connexe

En vedette

Pgdca final syllabus_2007_revised_31st_july_2007
Pgdca final syllabus_2007_revised_31st_july_2007Pgdca final syllabus_2007_revised_31st_july_2007
Pgdca final syllabus_2007_revised_31st_july_2007litu9439
 
3.Sangameshwar college Solapur Hindi Dept
3.Sangameshwar college  Solapur  Hindi Dept3.Sangameshwar college  Solapur  Hindi Dept
3.Sangameshwar college Solapur Hindi DeptSanghprakash Dudde
 
pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )
pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )
pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )Chand Rook
 
Indiahindiblog hindi thought
Indiahindiblog hindi thoughtIndiahindiblog hindi thought
Indiahindiblog hindi thoughtIndia Hindi Blog
 

En vedette (6)

Basics PHP
Basics PHPBasics PHP
Basics PHP
 
Pgdca final syllabus_2007_revised_31st_july_2007
Pgdca final syllabus_2007_revised_31st_july_2007Pgdca final syllabus_2007_revised_31st_july_2007
Pgdca final syllabus_2007_revised_31st_july_2007
 
3.Sangameshwar college Solapur Hindi Dept
3.Sangameshwar college  Solapur  Hindi Dept3.Sangameshwar college  Solapur  Hindi Dept
3.Sangameshwar college Solapur Hindi Dept
 
Computer basic course
Computer basic courseComputer basic course
Computer basic course
 
pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )
pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )
pcb making in hindi pdf( पीसीबी बनाने की विधि हिंदी में )
 
Indiahindiblog hindi thought
Indiahindiblog hindi thoughtIndiahindiblog hindi thought
Indiahindiblog hindi thought
 

Android eBook in Hindi

  • 1. Android in Hindi Third Edition V.K. Sharma www.besthinditutorials.com V.K. Sharma www.besthinditutorials.com 12/1/2015
  • 2. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Android in Hindi Third Edition V.K. SHARMA www.besthinditutorials.com
  • 3. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com ©Copyright 2015 by www.besthinditutorials.com This EBook may not be duplicated in any way without the express written consent of the publisher, except in the form of brief excerpts or quotations for the purpose of review. The information contained herein is for the personal use of reader and may not be incorporated in any commercial programs, other books, databases, or any kind of software without written consent of the publisher. Making copies of this EBook or any portion thereof for any purpose other than your own is violation of copyright laws. This edition has been published by www.besthinditutorials.com Limits of Liability/disclaimer of Warranty: The author and publisher have used their best efforts in preparing this EBook. www.besthinditutorials.com makes no representation or warranties with respect to the accuracy or completeness of the contents of this book, and specifically disclaims any implied warranties which extend beyond the descriptions contained in this paragraph. No warranty may be created or extended by sales representatives or written sales materials. The accuracy and completeness of the information provided herein and the opinions stated herein are not guaranteed or warranted to produce any particular results and the advice and strategies contained herein may not be suitable for every individual. www.besthinditutorials.com shall not be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages. Trademarks: All brand names and product names used in this EBook are trademarks, registered trademarks, or trade names of their respective holders. www.besthinditutorials.com is not associated with any product or vendor mentioned in this EBook. Reprint Edition: 2013 Published By: www.besthinditutorials.com
  • 4. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Contents 1. INTRODUCTION TO ANDROID 1.1. History of Android 1.2. Features of Android 1.3. OO principles of java 1.4. Java vs. c and c++ 2. ANDROID DEVELOPMENT TOOLS 2.1. Creating an application 2.2. Hello world program 3. ANDROID COMPONENTS 3.1. Activity 3.2. Services 3.3. Content provider 3.4. Broadcast receiver 4. ACTIVITY 4.1. Introduction 4.2. Creating an activity 4.3. Example 5. SERVICES 5.1. Introduction 5.2. Creating a service 5.3. Example 6. CONTENT PROVIDERS 6.1. Introduction 6.2. Creating a content provider 6.3. Accessing a content provider 6.4. Example 7. BROADCAST RECEIVER 7.1. Introduction 7.2. Creating broad cast receiver 7.3. Example 8. INTENTS 8.1. Introduction 8.2. Working of intents 8.3. Creating intents 9. VIEWS 9.1. Introduction 9.2. Types of views 9.3. Adding views to activity
  • 5. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com 10. FRAGMENTS 10.1. Introduction 10.2. Types of fragments 10.3. Creating fragments 11. LAYOUTS 11.1. Introduction 11.2. Attributes of layouts 11.3. Types of layouts 12. RESOURCES 12.1. Introduction 12.2. Types of resources 12.3. Supplying resources 13. DIALOGS 13.1. Introduction 13.2. Creating dialogs 13.3. Adding buttons 13.4. Adding lists 14. NOTIFICATIONS 14.1. Introduction 14.2. Creating notifications 14.3. Taking actions 15. MENUS 15.1. Introduction 15.2. Options menus 15.3. Context menus 15.4. Popup menus 16. BUTTONS 16.1. Introduction 16.2. Steps to create buttons 16.3. Creating buttons 16.4. Desingning buttons 17. TEXT FIELDS 17.1. Introduction 17.2. Creating text fields 17.3. Input types 18. SPINNERS 18.1. Introduction 18.2. Defining spinners 18.3. Creating spinners 18.4. Responding to selections 19. SEARCH INTERFACE 19.1. Introduction
  • 6. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com 19.2. Creating search interface 20. FILE SYSTEM 20.1. Introduction 20.2. Core directories 21. STORAGE SYSTEM 21.1. Introduction 21.2. Storage options 21.2.1. Shared preferences 21.2.2. Internal storage 21.2.3. External storage 21.2.4. SQLite database 21.2.5. Network Connection 22. Index
  • 7. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Preface The idea of writing a book about Android Development in Hindi can be somewhat futile at times, considering the pace at which android continues to expand, morph and change. What started out as a book project two years ago has now become a series of updates to the original work with the page count nearly double the original project and that after making hard decisions about what to leave out of the book to make sure it gets liked. This update to Android in Hindi represents our latest effort to provide coverage on important Android Development topics, namely the expansion into the tablet. Like many things in life, the only constant is change, but by now we are somewhat accustomed to the rapid-fire environment of Android Development. To the end, we have ensured that all the programs work with android studio as well as without android studio. The third edition is written by Vipin Kumar Sharma. Thank you for learning and collaborating with us. VIPIN KUMAR SHARMA
  • 8. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Acknowledgement Writing a third edition of Android in Hindi feels somewhat like the old saying about weddings: “Something old, something new…” The deadline for the third edition did not become any easier as at last count there are still only 24 hours in the day. And as for something new it seems as though android’s pace of innovation is continuing to match its adoption rate by users around the globe. In particular, we’d like to acknowledge and thank everyone at www.besthinditutorials.com. Firstly I would like to thank our EBook Designers and editors, who have been involved in every aspect of now three editions of this project. I would also like to thank our publisher to bring this masterpiece in EBook format.
  • 9. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com About this book Android in Hindi, Third Edition is a revision and update of the second edition published in 2013. This third edition adds new content related to android 5.0. Like its predecessors, this book covers important beginner topics such as “What is Android?” and installing and using the development environment. We than advance to practical working examples of core programming topics any developer will be happy to have at the ready on the reference shelf. The remaining chapter’s present detailed example applications covering advanced topics, including Widgets and UI. Although you can read the book from start to finish, you can also consider it a few books in one. If you are new to android focus first on beginning chapters. With the foundation you can work your way up to last chapter. Who should read this book? We wrote this book for professional programmers and hobbyists alike. Many of the concepts can absorbed without specific android knowledge. If you have c, c++ or c# knowledge, you will be able to follow the examples. Prior android studio experience is helpful, but not required. A number of good resources are available on java and android to augment the content of this book. And lastly the person who is willing to learn java in his mother tongue Hindi should read this book. Road map 1. BASIC – FIRST 10 CHAPTERS CONTAIN BASIC INFORMATION REGARDING ANDROID PROGRAMMING. 2. INTERMEDIATE – NEXT 10 CHAPTERS ARE SOMEWHAT OF INTERMEDIATE LEVEL AND NECESSARY ANDROID TOPICS. 3. ADVANCED – REMAINING CHAPTERS COVERS SOME ADVANCED TOPICS OF ANDROID DEVELOPMENT.
  • 10. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 1 Introduction This chapter covers  Introduction to android  Android versions  Features of android  Android platform Introduction to android Android एक ओपन linux based ऑप . ए क 2009 प क . Android क Open Handset Alliance न प क , क औ क पन क ओपन एक organizations क प क न क ए क क . ए न प क क . Android versions ए क क क 10 versions आ क . ए क version ए क नए ऐ क . आ ए क versions क नन क क . Android Versions आपक प न ए . Android 5.0 Lollipop - ए क version 12 न 2014 क क . ए क version guest login support, 64 bit CPU support औ 15 new language support कई नए ऐ क ए .
  • 11. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Android 4.4 KitKat - ए क version 31 2013 क क . ए क version audio monitoring, GPS support औ wireless printing कई नए ऐ क ए . Android 4.1 JellyBean - ए क version 9 ई 2012 क क . ए क version audio chaining, group messaging औ security enhancement नए ऐ क ए . Android 4.0 Ice Cream Sandwich - ए क version 18 2011 क क . ए क version inbuilt photo editor, ability to access apps directly from lock screen, wifi direct or face unlock कई नए ऐ क ए . Android 3.0 Honeycomb - ए क version 22 2011 क क . ए क version home screen widget औ support for multi core processor नए ऐ क ए . Android 2.3 Gingerbread - ए क version 6 2010 क क . version download manager, improved user interface, efficient battery औ improved gmail app कई ऐ क ए . Android 2.2 Froyo - ए क version 20 ई 2010 क क . ए क version क USB tethering, adobe flash support औ wifi hotspot functionality नए क क . Android 2.0 Eclair - ए क version 26 2009 क क . version bluetooth support औ google map कई नए features ऐ क ए . Android 1.6 Donut - ए क version 15 2009 क क . ए क version gallary, camera औ quick search box कई ऐ क ए . Android 1.5 CupCake - ए क version 27 2009 क क . ए क version auto-rotation, copy and paste, animated screen transition औ support for video recording include क ए . Features of android
  • 12. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com ए एक आ . Android features ए क न . ए क क न न - 1. User Interface - ए एक औ क क क न आ न . 2. Multiple Language Support - ए क प क . 3. ए messaging, web applications औ video calling क प क . 4. Media - ए media formats(mp3, jpg, mp4, flv) क प क . 5. Connectivity - ए bluetooth, wifi औ hotspot क न क कन क . 6. Storage - ए न क ए ए क न क आप क न क क . 7. Applications - ए आप पन न प applications क . 8. Open Source - ए एक ओपन ऑप क क प क ए . Android platform ए एक एन न क ए प क क ई न . Android platform क न आ न क न -
  • 13. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com  Linux based OS - न प न क ए एक प एन न . न kernel एक abstraction क आप क पन क प क क . न ऑप कप न ए c औ c++ प क ए  Dalvik Virtual Machine - क ए virtual न . आप ए क ई ए क न न . आप ए क न क क क compile क क क क . क क क ए क क क dex files क . क क क न क क क न क ए java virtual machine क न dex files क न क क क न क ए delvik virtual न क .
  • 14. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com  User Interface - ए क . ए क ए क क क प क क .  Applications - ए क न क ए न क क ए प न . पन प क क क क . ए क क प क .  Libraries - ए औ क ए प क ए .  Frameworks - ए क क प क ए क क क ए क न ए क ए कप न ऐ क क ए क न न न क क क न क ए क न न क न .  Multimedia support - ए प क ए औ क .ए आप क क क .
  • 15. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 2 Android Development Tools This chapter covers  Android SDK  Android debug bridge  Gradle  Android studio  Android runtime and delvik Android SDK Android SDK नक आपक ए ए क न ए क न , क प क न औ ए क न क पक क न क ए प Android SDK आपक क क प , प , एक औ ए क न प क न क ए . ए क न प क औ क न प न क . Android Debug Bridge ADB android SDK क एक क न क आप पन ए क न क क प न क क औ क क . एक एक , एक औ एक न (daemon ) . प न प न , प न प एक क क न औ न प क क न . Gradle Gradle एक ए . क ए क न क (पक ) क न क . क औ क आ न reuse क क . एक ए क न क कई variants
  • 16. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com आ न ए क क . क क क न आ न . Gradle आ न IDE क . Android studio Android Studio ए ए क न प क न क ए ऑ IDE . Android Studio क क न ए -  Android Studio .  ए औ एक कई apk आप android studio generate क क .  क न ए क न क न क ए ए क प क .  Android Studio एक आ ए क आप औ प क क ए क क .  Android Studio performance, usability औ version compatibility क क क न क ए lint क क .  Android Studio google cloud platform क ए built in support क . Android Studio क आप Eclipse IDE क क . क ए आपक ADT plugin क आ क कन क Android Studio Official IDE ए न android studio क क Android run time and Dalvik न ए ए क न क न न क ए एन न क . कन ए 5.0 ART क क . औ प क versions Dalvik क न क क . ART Dalvik क Dex Files क execute क . ART औ Dalvik एक एक क प , ए क ई application Dalvik क ए प क ART आ न क . ART Ahead-Of-Time( AOT ) कप न क introduce क . ART न verification delvik .
  • 17. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 3 Android Components This chapter cover  Activity  Services  Content provider  Broadcast receiver Android Activity आपक application GUI Screen activity . एक GUI Screen औ activity one to one relationship . MVC paradigm controller view क control क क एक activity आपक android application GUI Screen क control क . आप पन android application न GUI Screen आपक न activity create क न . activity एक GUI Screen क display क . user GUI Screen क क ई events generate क activity न events क handle क न क ए responsible . कई activity system generated events क handle क . GUI Screen elements display क न क ए activity views क . view एक different element क represent क . Views क न नक आप Android in Hindi:Views tutorial क . Android activity create क न क ए आपक Activity class क extend क न . क न - Public class yr_cls_nm extends Activity { }
  • 18. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Android Service क application क क execute न service क implement क न . आप एक service launch क क औ क प न प terminate क क . Services background run औ नक user interface न . एक android service create क न क ए आपक Service class क extend क न . क न - Example public class yur_cls_nm extends Service { } Android broadcast receiver Intents क notification प न क ए एक application क क broadcast receiver क register क न . क application क register क न क ए आपक AndroidManfest.xml file receiver element क include क न प . औ क name attribute पन class क न प क न . प आपक dot operator (.) न . क न - Example <receiver android:name=".yourclassname"> </receiver> receiver tags आप intent-filter क क . Example <receiver android :name =".yourclassname "> <intent-filter> <action android:name ="action_name">
  • 19. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com </intent-filter> </receiver> Android content provider एक application पन data क application क share क न ऐ content provider क क क क application क data क content provider store . एक application क application क data क access क न application क content provider क ए क . Content provider क methods क application क access क न क permission . 4 primary components android application . Android components क न android क न क ए .
  • 20. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 4 Activity This chapter covers  Introduction  Starting an activity  Activity life cycle  Launcher activity  Creating new activity  Destroying an activity Introduction to activity आप क application एक activity क आप न activities क navigate क , न एक activity activity activity पन life cycle क different stages क ए आपक activity start foreground औ user क प focus प process क न android system क life cycle methods क call क user क ई activity start क android system activity क life cycle methods क call क औ आपक प activity background Life cycle methods आप decide क क क user प आ आपक activity क behave क क ए आप एक player न user क activity प video streaming क न ए कन आप एक music player न आप music क background play क क . Starting an activity programming paradigms क ई ए क न main Android android system activity क life cycle methods क initiate क Activity क start क न क
  • 21. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com ए methods क sequence औ activity क close क न क ए methods क sequence Understanding activity life cycle methods Activity क life cycle क न android system set of methods क call क क activity क life cycle एक step pyramid क Activity life cycle क stage separate क android system activity क start क method activity क एक step forward क औ activity top क प Activity क top stage activity running stage औ visible user क interact क क user activity क क activity क stages pyramid न क move क न औ last stage क activity destroy क cases activity wait क क user application प switch क activity background wait क औ user प आ activity resume आप क application क complexity क ए न क आप life cycle methods implement क न कन क आप क methods आ औ आपक ए क न क behavior क ए आप methods implement क क Activity क life cycle stages क क information न Created - stage onCreate() activity create क user आपक application क icon प क क Started - stage onStart() activity start क Resumed - stage activity running stage औ user क visible Paused - stage activity paused user क application switch क Stopped - stage activity stopped Destroyed - stage activity destroyed Launcher activity
  • 22. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com क ई user आपक ए क न क icon क click क android system activity क onCreate() क call क आपन launcher declare क Launcher activity activity आपक ए क न क main activity आपक ए क न कई activities क कन प activity user क visible आपन launcher main declare क क न activity main activity आप AndroidManifest.xml declare क क Main activity क <intent-filter > क declare क न ए action MAIN औ category launcher MAIN action launcher category defined न आपक application क icon न Example Creating a new activity applications activities न user क perform क activity main activity user क ए क न icon क क क न create क ई activity आपक ए क न user interact क ए create क , android system activity क create क न क ए onCreate() method क क आपक onCreate() क implement क न , आप application क startup logic प क क क activity क प life cycle क एक क क ए आप पन implementation user interface define क क औ क variables instantiate क क onCreate() method क execution , android system onStart() औ onResume() method क क क आपक activity created औ started stages प क न आ Technically activity onStart() क क visible कन क
  • 23. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com onResume() method क activity क resume state activity क resume state क क change न Destroying the activity Activity life cycle क प onCreate() औ last onDestroy() Android system आपक activity प क क क क signal क आपक activity android system क memory completely remove न applications क onDestroy() क implement क न क न क local references activity क कन आपक ए क न background threads आपक onDestroy() method क implement क न ए
  • 24. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 5 Services This chapter covers  Introduction  Declaring service  Creating a service o Started service o Bounded service Introduction to android services प क आप न क service आ न क service न -  एक service separate न आपक ए क न क प  एक service thread न आ service -  Service एक facility आप android system क क क आप क ई क background क न  Service एक facility एक ए क न पन क functionality applications क expose क क  service क <service> declaration AndroidManifest.xml file न ए Services क आप context.startService() औ context.bindService() क क  service component ए android system component क initiate क औ क onCreate() क क क . life cycle method execute service प depend क क क क क complete क न
  • 25. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com एक service क 2 forms क Started - एक service started service क क ई component startService() क क एक न क service क execute ए क न component destroy operation क प service automatically stop Bounded - एक ए क न bound क ई component bindService() क क क service क bind क एक bound service client server interface क component service क interact क क एक service create क न क ए आपक एक create क न प base Service क extend क . एक service callback आप implement क क औ appropriate stage प पन क क प क क क service क आप 2 क क एक आप startService() क क क आप bindService() क क क Service base क methods क आप पन क implement क क क important न ए - onStartCommand() - Android system क क क क ई component क क ई activity startService() क क क service क start क न क ए request क क service औ क execute आप क implement क stopService() क क क service क प क न आपक onBind() - Android system क क क ई component bindService() क क क service क bind न आप क implement क आपक एक interface क न ए clients service communicate क क onCreate() - Android system method क क क service ए एक क onDestroy() - Android system क क क service पन क प क औ destroy
  • 26. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com क ई component service क startService() क क क क service क न क stopSelf () क क क क प न क component stopService() क क क service क प क क ई component service क bindService() क क क क service क न क क component service bound service clients unbound android system service क destroy क Android system service क forcefully stop क memory क औ क user focus activity क ए resources क न Declaring service in AndroidManifest.xml file Activities क आपक services क AndroidManifest.xml file क न Service क क न क ए आप <service> ए क <application> ए क child क क औ attribute आप service ए include क क औ properties क न क क service क क न क ए permissions औ process service न आप न क क android : name attribute आप service specify क Creating a service Started service एक started service service components startService() क क क क service start क एक life cycle क न component
  • 27. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com क न component destroy service क न Started service create क न क ए प 2 available - Service - services क आप क ए क क आप services क क क न क ए एक न thread ए क क by default service main thread क क ऐ न आपक activity क performance slow IntentService - Service क sub class . request क क न क ए class एक worker provide क . कन एक एक request क क आपक ए क न एक requests क क न न न IntentService क implement क न आपक ए ऑ न आ नन क क क आप क component activity क क क क - क component service क न क ए आप startService() intent प क क Android system service क onStartCommand() क क औ intent प क Example Intent yrIntent = new Intent(this, yrclass.class); startService(yrIntent); आ क service क stop क क - Started service क stop क न क android system क न . Service क stopSelf() method क क क क stop क न क ई component stopService() क क क service क stop क क Bounded Service एक bounded service service क components bindService() क क क bind आपक bound service create क न ए आप क activity औ components service क interact क क Bound service क आप पन ए क न क क functionality ए क न क expose क क
  • 28. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Bound service ए क न क ए आपक Service क onBind() method implement क न एक IBinder return क service क communication क ए interface define क components bindService() क क क interface क क service bounded components destroy न क क service destroy न
  • 29. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 6 Content Provider This chapter covers  Introduction  Accessing content providers  Creating content providers Introduction to content provider आप पन application क applications क share क न आपक पन application content provider create क न Content providers क access क manage क Content providers क encapsulate क औ क application security provide क Content Provider create क न क ए आपक Content-Provider class क extend क न class Content-Provider क extend क क ऑ क provider object क . आप content provider data access क न क ए आपक Content-Resolver क object क न Content provider आप एक client क access क Content-Resolver provider object communicate क .
  • 30. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com एक content provider applications क tables क form present क row क type क represent क औ column data क एक part क represent क क ई application क application access क न Content- Resolver क एक client क application क provider object क request क provider object request प action , औ results प क database query क न आप applications क data share न क न आपक content provider create क न क आ क न कन आप पन ए क न क search क न आपक content provider क Accessing content provider क न आपक प content provider access क न क ए आपक Content- Resolver class क object क न Content-Resolver object क methods provider object same न क methods क क क Content-Resolver object क methods क आप क basic operations क create, retrieve, update औ delete प क क Content-Resolver methods Content-Provider ए आप Content-Resolver क ई method क क method same न क क Content- Provider क क क ए आपक application content क access क न क ए Content-Resolver query() method क क Content-Provider क query() method क क क Content provider न methods न ए Content provider available आप क न data access क न आपक define क न क ए आप content U-R-I क क क Content U-R-I U-R-I content provider क identify क Content U-R-I प आप content provider क न आप table access क न क न
  • 31. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 7 Broadcast Receivers This chapter covers  Introduction  Creating broadcast receivers  Registering broadcast receivers Introduction to broadcast receivers Broadcast receivers android components नक आप applications औ system generate न events क notification प क क event क नक प न क ए आपक application क event क ए क register क न प क ई application ऐ एक broadcast receiver ए क क क क क ई event generate android system न application क notify क न event क ए क क Creating broadcast receivers Broadcast receivers ए क न क ए आपक BroadcastReceiver क extend क न BroadcastReceiver क onReceive() क आप पन implement क क onReceive() method आप न क क event receive क न क आप क न Example yourclasss extends BroadcastReceiver { @Override public void onReceive(Content context, Intent intent)
  • 32. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com { //your implementation of onReceive() method. } } Registering broadcast receivers Broadcast receiver ए क न क आपक intent क ए register क न ऐ आप AndroidManifest.xml <receiver> element क define क क क <receiver> element क android:name attribute आप BroadcastRecevier क extend क न क न क आप <receiver> ए क <intent-filter> element क औ क sub element <action> intent क न क ए आपक broadcast receiver register क न Example <receiver android:name=".yourClassName"> <intent-filter> <action android:name="Name of intent that you want to listen"> </intent-filter> </receiver>
  • 33. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 8 Intents This chapter covers  Introduction  Types of intents  Intent filters Introduction to android intents Intents क आप क न . क  contacts list न .  क क क न  messages क न आप क न आप ए क क एक क . Intents messages android components(Activity, Service, Broadcast receiver, Content provider ) एक क . एक component क component क क functionality क ए request क . request messages क क intents क . Intents asynchronous messages क android components एक messages क क . Intents क आप same ए क न कप न क क क औ ए क न क कप न आप intents क क क . क ए क ई activity activity क क क क contacts क क
  • 34. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com android.content.Intent android system क आप ऑ ए क औ न ऑ आप क न (ACTION) औ आपक क प न (URI of Target Component) आप आ क प क . आपक Activity क क न प आप Android in Hindi : Activity tutorial क . क activity क क न क ए प आपक intent ए क न क आप startActivity() क क क intent क आ क प क एक ए ए Example Intent contactsIntent = new Intent(Intent.ACTION_PICK,Uri.parse("Content://contacts/people")); startActivity(contactsIntent); example प न एक intent ए क न न contactsIntent. Intent ए क न क क क न . क न न क क क न . क न startActivity() क क न क प क . एक ए क क क क क .
  • 35. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Services क नन क ए आप Android in Hindi : Services क . न एक ए क क आप एक Service क क . क ए आपक startService() क क क प क न Example Intent contactsIntent = new Intent(Intent.ACTION_PICK,Uri.parse("Content://contacts/people")); startService (contactsIntent); Broadcast messages android system . एक broadcast receiver ऐ messages क ए register क क . generate notification message . Types of intents Intents 2 क Implicit intent औ Explicit intent. Implicit intent क आपन एक intent ए क क एक ए क ओपन क . कन android system एक browsers क . एक target (Browser ) directly open न न browsers नक ए क क औ क intent execute Explicit intent Explicit intents आप प न क क intent क क ए न . क आपन एक intent ए क एक ए ओपन क आप प न क क Google Chrome क execute न . क प न प न क . Intent filters आपन एक application ए क क एक browser . क pdf reader क ए क क प क क एक generate . आप क आपक ए ओपन आपक intent intent filter पन application क component क ए declare क न
  • 36. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com क ई intent generate registered ए क न कप न क message औ क according ए न . आप क आपक ए क न intents क receive क क आपक पन ए क न क intent क ए register क न Intents क ए register क न क ए आपक intent-filter क न . आपक AndroidManifest.xml क नन आप Android in Hindi : AndroidManifest.xml file tutorial क . intent filters आप AndroidManifest.xml ए क . Example <intent-filter> </intent-filter> Intent filters क 3 element tags .  <action > - आप न क क आप क क action क ए intent filter न क . एक ए क न कई intents generate क क . कन आप नक ए न क आ प प न क . Action न क न क ए andorid : name attribute क .  <data > - आप न क क आप क क क ए intent filter न क . basically components क URI . क define क न क ए android : scheme attribute क .  <category > - आप intent क category define क . आप default-category क क . Category न क न क ए android : name attribute क . ए न आप intent ए क न क action आप action . औ आप Component क URI . Explicit intents target component न क . कन implicit intents target component न न . ए न application क implicit intents receive क न intent filters क . intent ए notification message .
  • 37. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 9 Views This chapter covers  Introduction  Different Android views  Common methods Introduction to android views Android views ए क Android views elements न प , क button, text-box आ views activity क Android view classes, views क represent क android view एक view class क represent क क button क represent क न क ए Button class provide क न classes क events क user interact क Android views क form represent क activity views hierarchical tree क form represent क views क size न views क android platform include क आप क android views create क क Android platform included views क आप क views create क क आप views क directly code क XML file आप क क Common android views आप क single ए क view क views क एक क layout क show क view-group क
  • 38. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com View's View class क Analog-Clock, Progress-Bar, Image-View, Surface-View, View-Group, Text- View औ View-Stub classes extend क Text-View - Text-View view क extend क Text-View क Edit-Text, Digital-Clock, Chronometer, Checked-Text-View औ Button classes extend क Button class क Compound-Button class extend क Compound-Button class क Radio- Button औ Check-Box Classes extend क Image-View - Image-View class क Image-Button class extend क class image buttons ए क न क ए क Surface-View - Video-View Surface-View class क extend क screen प video क न क ए क Analog-Clock - class screen प analog clock ए क न क ए क Progress-Bar - क process क ए progress bar ए क न क ए क View-Stub - views क ए layout ए क न क ए क View-Group's View-Group View क ए क View-Group क Map-View, Adapter- View, Relative-Layout, Linear-Layout, Frame-Layout औ Absolute-Layout extend क Map-View - क screen प प क क क Adapter-View - Spinner, Grid-View, Gallery औ List-View classes Adapter-View क extend क Relative-Layout - क Dial-er-Filter औ Two-Line-List-Item ए क classes views क ए relative layout provide क Linear-Layout - Table-Layout, Table-Row, Radio-Group, Tab-Widget, Zoom-Controls Linear-Layout क extend क views क ए Linear layout क
  • 39. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Frame-Layout - Scroll-View, Time-Picker, Date-Picker, Ticker, Scale-Layout, View- Animator Frame-Layout क extend क views क ए frame layout क Absolute-Layout - क Web-View extend क views क ए Absolute-Layout provide क Common methods used with android views  set-Background-Color(int Color) - background color set क न क ए क  set-Background-Draw-able(Draw-able d ) - एक draw-able background क न क ए क क क ई image आप background क क  set-Clickable(Boolean c) - आप element प आप क क clickable न क  set-Focus-able(Boolean f ) - आप ए क focus-able न क  set-Layout-Pa-rams(View-Group.Layout-Pa-rams l ) - क आप आ क position औ size क क  set-Minimum-Height(int min-Height) - आप ए क minimum height क क  set-Minimum-Width(int min-Width) - आप element क minimum width क क  set-On-Click-Listener(on-Click-Listener l) - आप एक listener क क क events generate न प respond क क
  • 40. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 10 Fragments This chapter covers  Introduction  Life cycle of fragments  Types of fragments  Creating android fragments Introduction to android fragments एक fragment क activity क एक separate UI (user interface) Fragments क क life cycle औ input events आप एक fragment क कई activities क क आपक activity running state आप fragments क add औ remove क क Fragments क आप sub activity क क
  • 41. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Android fragments क android क Honeycomb version introduce क Android fragments प आप user क एक एक activity क क ए आप न क parts divide न क क Fragments क आन application design औ flexible क आप क एक एक interface क क औ separately manage क क आपक प activity एक कन आप fragments add क क एक fragment activity embedded न ए Fragments क life cycle activity क life cycle directly affected क ए activity pause क fragments pause activity destroy ए क fragments destroy activity running state आप क fragments क independently manage क क आप fragment क ऐ क fragment आपक activity क view hierarchy क View-Group , औ क view layout न क आप fragment क activity layout क क ए आपक activity layout file <fragment> क क न क क fragment क activity layout क प न न क क ई आ क न आप fragments क न UI क ए क क क प प पन क क क Basically fragments क tablet devices क ए design क , क tablet devices प space क आप fragments क आ न क क Activity क layout क fragments divide क क आप screen क appearance क क क क ए आप एक fragment screen क left side links क list provide क क , औ right side क fragment न articles क open क क आपक fragments क design क न ए क एक fragment कई activities क क fragment क क layout औ क life cycle ए आपक fragments क ऐ design क न ए क एक fragment क आप कई activities क क
  • 42. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com ऐ क न ए आ क क आप fragments क different screen sizes क क आप पन application क tablet औ handset न devices क ए न आप fragment क configure क क क न devices प आ न न क Fragments life cycle Creating Fragments Fragment create क न क ए आपक Fragment क extend क न Fragment Activity क आप प ए क activity life cycle औ fragment life cycle ऑ same आपक life cycle methods क implement क न क आ क न , कन आपक onCreate(), onCreateView() औ onPause() methods क क न ए Fragment क 3 important sub class’s आप ए क क -  DialogFragment - एक floating dialog ए क न क ए क क Dialog ए क न क ए क क न एक alternative  ListFragment - एक items क display क आप adapter manage क क
  • 43. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com  PreferenceFragment - preference ऑ क hierarchy क एक क क Declaring fragments in layout file Fragments क layout file declare क न क ए आपक <fragment> element क न element क एक important attribute android:name, आप क न प क fragment क extend क <fragment> element android:id attribute , आप एक नक id प क Example <fragment android:name="class name which extends Fragment class" android:id="ïd"> </fragment>
  • 44. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 11 Layouts This chapter covers  Introduction  Attributes of layouts  Types of layouts Introduction to android layouts क न आपक प आप views ए क order आपन ए क एक क कई ऐ क क आप क view क screen प एक particular position प place क न ऐ आप android layouts क क क Layouts क ए structure क structure क according आप पन elements न प न क क Android system कई क layouts provide क आपक ए क न क ए layout आपक क आप क क Android layouts आप 2 define क क आप एक XML क ऐ क क run time view औ view groups क objects ए क क ऐ क क आप क पन क आप न क पन क आप XML क ए क ए layouts क run time क क आप layouts XML क क आप पन ए क न क view क औ ए क न क behavior क control क क Attributes of android layouts न क common attributes ए views क
  • 45. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com  android:id - attribute क आप view क id define क view क uniquely identify क न क क आ  android:layout_width - attribute क आप view क screen प width define क  android:layout_height - attribute क आप view क न प height define क Types of android layouts Linear layout Linear layout एक ऐ layout elements एक direction vertical horizontal. आप layout क direction android:orientation attribute क define क क layout क direction vertical एक column एक ए आए औ layout क direction horizontal एक row एक element आए आप क एक particular element क priority क layout weight क ऐ आप android:layout_weight attribute न क क क क element क न weight न space screen प cover क क element क weight क elements क elements क set न क remaining space element cover क Linear layout ए क न क ए आपक XML file <LinearLayout> element declare क न element क android:layout_width, android:layout_height औ android:orientation 3 attributes न न attributes क ए values provide क क आप layout क set क क Example <LinearLayout xmlns:android="android schema address" android:layout_width="width of layout" android:layout_height="height of layout"
  • 46. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com android:orientation="layout orientation"> <Button android:layout_width="width of button" android:layout_height="height of button" android:text="name of button" /> <Button android:layout_width="width of button" android:layout_height="height of button" android:text="name of button" /> </LinearLayout> Relative layout Relative layout view elements क relative positions प display क view क आप elements क relation position क क क नए view क position आप existing view क relation define क क आप existing element क right नए element क set क न left क आप क element क screen प क place क क Relative layout views क position क न क ए क attributes provide क , नक आप पन view क position क क आ न attributes क नन क क - android:layout_alignParentTop क view element attribute क value true view आप क न top प android:layout_centralVertical क view element attribute क view आप क न vertically center android:layout_below
  • 47. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com attribute आपक view element क view क न position क आपन resource id क define क android:layout_toRightOf attribute आपक view element क view element क right place क आपन resource id क define क प क ए ए attributes आप पन आ क क न क क Example <RelativeLayout xmlns:android="android schema address" android:layout_width="width of layout" android:layout_height="height of layout" android:paddingLeft="in dp" android:paddingRight="in dp"> <Button android:layout_width="width of button" android:layout_height="height of button" android:layout_below="id of other view element" andorid:text="name of button" /> <Button android:layout_width="width of button" android:layout_height="height of button" android:layout_centralVertical="id of other view element" android:text="name of button" /> </RelativeLayout>
  • 48. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com ListView ListView एक view group items क list क आप scroll क क layout run time views क न क क layout एक column औ row न आप एक row एक view position क क Run time आप adapter क क array database item क pull क adapter item क view convert क क list क आ add क GridView GridView एक view group items क two dimensional grid क grid क आप scroll क क layout items rows औ columns क form GridView items run time प automatically insert
  • 49. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 12 Resources This chapter covers  Introduction  Alternative resources  Supplying resources  Retreiving resources  Types of resources Introduction to android resources क न आपक प resources files आपक ए क न code include क Resources क application क code separately maintain क Resources क ए क न separate क न आप resources क independently maintain क क Resources क आपक ए क न directory क /res folder maintain क Android studio /res folder क position न window
  • 50. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com /res क sub directories औ न maintain क न resource types क न Alternative resources devices क configuration क tablet device क screen size mobile device ए application क device configuration क support क न क ए alternative resources क न ए आपक ए क न run android device configuration क detect क औ device क according resources load क Alternative resources न क न क ए आपक /res <resources-name>- <config_qualifier> directory ए क न
  • 51. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 13 Diaglogs This chapter covers  Introduction  Creating dialogs  Adding buttons  Adding lists Introduction to android dialogs Dialog एक window क ई decision क क information input क क Dialog प screen क cover न क Android dialogs 3 क -  Alert dialog - एक simple alert dialog क dialog आप title क क , 3 न add क क औ items क list क क select क क dialog ए क न क ए आपक AlertDialog क extend क न प  Date picker dialog - क dialog आप क एक window क क date select क क क dialog ए क न क ए आपक DatePickerDialog क extend क न  Time picker dialog - क dialog time select क क क dialog ए क न क ए आपक TimePickerDialog क extend क न classes Dialog क extend क न dialog क क न प आपक पन dialog क ए एक container ए क न क ए आप DialogFragment क extend क क DialogFragment dialog create क न औ क न क न क ए methods क
  • 52. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Creating android dialogs Android dialogs ए क न आ न क ए आपक 2 3 statements न Example AlertDialog.Builder yrobj = new AlertDialog.Builder(getActivity()); //creating alert dialog yrobj.setMessage(R.string.yrmessage); //setting message yrobj.setTitle(R.string.yrtitle); // setting title AlertDialog ad = yrobj.create(); // getting alert dialog from AlertDialog.Builder Dialog ए क न प आपक dialog fragment ए क न क ए आप DialogFragment क extend क आप onCreateDialog() क implement क औ आप dialog ए क Dialog ए क न क ए आप Builder क क Example public class yrclass extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // create yr dialog here as shown above } } आप क object प show() क क dialog
  • 53. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Adding buttons to android dialogs Android alert dialogs आप 3 क buttons add क क -  Positive button - button positive response क ए क क ok yes क न create क न क ए आपक setPositiveButton() method क call क न क आप alert dialog क object प क क 2 arguments प एक button क न औ DialogInterface क object interface onClickListener() provide क क आप implement क  Negative button - button negative response क ए क क no cancel क button dialog add क न क ए आपक alert dialog क ऑ प setNegativeButton() call क न  Neutral button - एक simple button आप क ई action क क button क simply android button create क create क Example DialogInterface.onClickListerner di = new DialogInterface.onClickListener(); // creating dialog interface object for event handling yrobj.setPositiveButton(R.string.button-name, di); // setting positive button public void onClick(DialogInterface di, int id) { //handle on click event here } आप negative button ए क क Adding lists to android dialogs Android alert dialogs आप 3 क list add क क -  Single choice list - क list क ई एक item select क क Item select प event generate औ code क according action  Single choice radio list - क क list radio buttons क show क User क ई एक select क क
  • 54. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com  Multiple choice check-box list - क list एक कई items select क क क list checkboxes क show Alert dialogs ए क न क ए आपक setItems() method क क न method 2 arguments प क एक list items क array औ DialogInterface.onClickListener interface क object क न ऊप button add क न क ए क DialogInterface.onClickListener क onClick क implement क क आप select event क क क ऊप setPositiveButton() method क आपन क आ setItems क structure - yrobj.setItems(R.Array.yrarray, DialogInterface.onClickListener di);
  • 55. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 14 Notifications This chapter covers  Introduction  Contents of android notification  Creating notifications  Taking action Introduction to android notifications Notifications आपक device top प battery औ signal icons क प आपन आपक device प क ई mail text message आ top प एक message icon messages notifications क क ई notification आ प क icon क क ई mail आ Gmail क icon क notification क detail नन notification drawer क open क devices notification drawer top bottom क swipe क open Notification drawer क क क क settings क WiFi, Bluetooth, screen brightness आ आप notification क क ई action क क notification प click क आपक application open actions क
  • 56. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Contents of android notification  Icon - एक icon notification related ए क न क represent क  Title - notification क title notification क purpose क  Detail text - detailed text message Creating a notification एक notification ए क न क ए प आप NotificationCompat.Builder क object ए क एक public static आ न notifications ए क न क ए एक builder आप current activity क reference प क क आप builder क object क notification क contents क Icon set क न क ए setSmallIcon() method क क औ icon क ए प क Notification क title क न क ए आप setContentTitle() method क क औ title string प क Detailed message set क न क ए setContentText() method क क औ text string प क क आप NotificationCompat.Builder क object प build() method क क method एक notification return क notification method return क contents क loaded आपन set क आ notification क issue क न क ए आप build method न notification object return क notify() प क क NotificationManager क object प क क Example NotificationCompat.Builder ncb = new NotificationCompat.Builder(this); // crating builder class object ncb.setSmallIcon(R.drawable.yricon); // setting icon ncb.setContentTitle("your notification title"); //setting title ncb.setContextText("your notification message");// setting text
  • 57. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Notification noti = ncb.build(); //creating notification NotificationManager nm = new NotificationManager(); nm.notify(noti); //showing notification Taking actions with notifications Android notifications क action न optional आप एक simple text message क क notification प क क क ई notification क क action क आप notification drawer क पन ए क न क Notification क आप कई क क action क आप notification button provide क क press क न प आपक application न open ए क ए न perform क notification प click क application क open क न common ए न action क ए आप builder क object प setContentIntent() क क औ PendingIntent क ऑ प क PendingIntent क object ए क आप normal intent क object प क intent application क open क न क action क define क Example Intent yrIntent = new Intent(this,yrActivity.class); pendingIntent pi = new pendingIntent(yrIntent); ncb.setContentIntent(pi);
  • 58. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 15 Menus This chapter covers  Introduction  Creating a menu in XML  Options menu  Context menu  Popup menu Introduction to android menus Menus क ए क न क एक क न क easy औ designer क न क ए आप menus क क क Menus क आप न ए ए 3 reasons क क क  User क application क components क link provide क न क ए  Application क structure क न क ए  navigation क ए Android menus 3 क - 1. Options menus 2. Context menus 3. Popup menus Creating a menu in XML layout file menu types क ए menu items न क न क ए android एक XML format क पन activity क क menu ए क न क ए आप आप एक XML layout file menus न क आप पन activity load क क ऐ XML layout file क menu resource क
  • 59. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com क ए प आपक पन क res/menu directory एक XML ए क न XML file menu ए क न क ए आप क elements क क आ न ए क नन क क <menu> - ए menu define क element menu items क base क क क आपक file प ए declare न ए क आप <item> औ <group> ए क <item> - ए एक menu item ए क item क ए आपक एक item element declare क न <item> element क attributes क क न ए android : id - एक नक id android system menu item क uniquely identify क android : icon - attribute क आप क image क item क icon क क क android : title - attribute आप item क title declare क <group> - element container क , कन एक menu items क एक न क ए क Example <menu xmlns:android="schema address"> <item andorid:id="1" android:icon="address of icon image" android:title="First Item"> <item andorid:id="2" android:icon="address of icon image" android:title="Second Item"> <item andorid:id="3" android:icon="address of icon image" android:title="Third Item"> </menu> Options menus क application क ए options menus primary menus Options menu आपक options न ए प application क control क क औ क option आप options menus क
  • 60. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com आप android gingerbread lower versions क ए ए क न develop क न न प क क क menus क क आप android honeycomb ऊप क versions क ए options menus develop क app bar क menus क access क क Creating options menus Options menu क ए items आप activity subclass fragment subclass क क आप न क items क interface न combine Activity क item प क order fragments क ऐ क आ नक items आप menu items क reorder क क क activity options न define क न क ए आपक onCreateOptionsMenu() क override क न क न @Override public boolean onCreateOptionsMenu(Menu menu) { // put menu resources in menu from XML } क आप न resources क न क आप आप add() क items क add क क औ न items क न क ए आप findItem() क क Context menus एक context menu option क क एक ए क effect क . ए न long click क क
  • 61. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Context menus movable menus क क ए प क क menu element क effect क न ऑ न क प न long क क आप android honeycomb higher versions क ए ए क न develop क selected elements प ए न प क न क ए आपक contextual action mode क न ए आप क view क ए context menu क क कन view groups क ए क क view groups elements प direct actions प क क Creating context menus Context menu ए क न क ए प आपक view क ए आप context menu ए क न क register क न क ए आपक registerForContextMenu() क क न औ view प क न क आपक onCreateContextMenu() क ओ क न registered view प long क क system क क क आप menu items define क क न - @Override public void onCreateContextMenu(ContextMenu contextmenu, View view, ContextMenuInfo contextmenuinfo) { // declare menu items and put menu resources } क आपक onContextItemSelected() क ओ क न क ई न क ई item select क system क क क आप item select न प task complete क न क क क न @Override public boolean onContextItemSelected(MenuItem item) { // perform desired task }
  • 62. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com getItemId() आप selected item क id प क औ item प action क Popup menus एक popup menu items क vertical list क Pop menus anchor view क available anchor view क न न anchor view क ऊप Popup menus ऐ options क same activity views क perform क क Creating popup menu आप menu क XML क define क न ऐ आप क क - प आपक PopupMenu क एक object ए क न Object ए क आप current application क context औ view pass क आप popup menu न क PopupMenu.getMenu() क क क आप क Menu क reference न औ MenuInflater क न resources put क न आ menu क क न क ए PopupMenu.show() method क क न
  • 63. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 16 Buttons This chapter covers  Introduction  Steps to create buttons  Creating buttons  Designing buttons Introduction to android buttons Buttons क ए क न क ए important element Button क click क न प button क ई action perform क क ए आपक button क coding क न button क एक न Android buttons क ए आप न क क ई icon क क Android buttons क एक न क औ icon Android buttons editable Android buttons क styling न क क ए आप different styles औ themes क क Button प click onClick event occur event क handle क न क ए coding क Steps to create android buttons प आप activity_main.xml file button add क क आप MainActivity.java file button क click event क coding क coding आप 2 क क
  • 64. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Creating android buttons Adding button to XML file Button क XML file ए क क ए आप <Button> element क <Button> ए क क attributes , न ए Android : layout_width - attribute क आप button क width set क क Android : layout_height - attribute आप button क height क Android : text = "string" - attribute क आप button क न Android : src = "@drawable/button_icon" - attribute क आप button क icon क क Example <Button Android:layout_width="width of button" Android:layout_height="height of button" Android:text="name of button" Android:src="icon of button" /> Handling onClick event onClick event आप 2 handle क क प क आप <Button> element क android:onClick attribute क क आप activity class एक method ए क method button क क न प क method क न आप android:onClick attribute प क Example In XML file <Button android:layout_width="width of button" android:layout_height="height of button" android:text="name of button"
  • 65. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com android:onClick="yourMethod" /> In your activity class public void yourMethod(View view) { // perform your task here } button प click क onClick attribute define क आ method क क आप XML न क क run time events handle क न क ए प क आप एक button object ए क औ button object प setOnClickListener() क क औ onClickListener क आप run time event handle क न क क क XML file क button ए क न easy Designing android buttons devices styles क ए आपक buttons devices प styles आप पन buttons क style क control क क क ए आप प ए क न प एक theme apply क Android आपक android:theme attribute provide क attribute क आप <application> element apply क element AndroidManifest.xml declared आप buttons क individually configure क न आप android:background attribute क क attribute आप क ई image प क क औ क ई क प क क
  • 66. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 17 Text fields This chapter covers  Introduction  Creating text fields  Input types  Keyboard actions Introduction to android text fields आप पन android application text fields ए क क Text fields क text boxes क एक text field क आप input क क न औ ई ए text fields एक न क कन आप android multiple lines क text ए क क Text ए क न क ए text field प क क क क क न प typing cursor text field प क न क ए keyboard automatically आप text fields क क input values क ए configure क क क क text box क आप email क ए configure क क Android text fields क ए आप actions define क क input क न क perform क Creating android text fields Text fields आप पन layout add क क क ए आप XML layout file <EditText> element define क <EditText> element क basic attributes view elements define क -
  • 67. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com  android:id - attribute text field क id define क  android:layout_width - attribute text field क width define क  android:layout_height - ए क आप text field क height define क  android:hint - attribute क आप input type क hint क  android:inputType - attribute क आप input type न क  android:imeOptions - attribute क आप action define क Example <EditText android:id="id for text field" android:layout_width="width of text field" android:layout_height="height of text field" android:hint="hint of input type" android:inputType="input type" android:imeOptions="action" /> Input types of android text fields Text fields क values क क text, number, date औ email address. एक text field आप क क enter क क आप android:inputType attribute क न क attribute क ए common input types न ए input types keyboard क  text - input type text enter क न क ए declare क normal text क क  textEmailAddress - input type email address नप क न क ए क normal keyboard @ sign क  textUri - नप प आप text field URL enter क क input type text keyboard क / क
  • 68. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com  number - input type numbers ए क न क ए क औ numbers क keyboard क  phone - input type क phone style keyboard क ए क  Example <EditText android:id="id for text field" android:layout_width="width of text field" android:layout_height="height of text field" android:hint="hint of input type" android:inputType="textEmailAddress" android:imeOptions="action" /> Keyboard actions of android text fields User क information input क न क action action आपक ए क न प depend क क आपक ए क न searching क service provide क action search क औ आपक ए क न messaging क service provide क action send क क क action आप न आपक application प न आप क ई action न न क next क option न right hand side corner न action आप न क Keyboard action आप android:imeOptions attribute क न क क Example <EditText android:id="id for text field" android:layout_width="width of text field" android:layout_height="height of text field" android:hint="hint of input type" android:inputType="textEmailAddress" android:imeOptions="actionSend" />
  • 69. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 18 Spinners This chapter covers  Introduction  Defining spinners  Creating spinners  Responding to selections Introduction to android spinners Android spinners आपक ए क न एक drop down menu drop down menu items user choices क user spinner प क क items पन ए appropriate choice choose क By default spinner top element Spinners क XML layout file ए क औ items क string resource file ए क आप एक string array ए क Spinner औ items क न क ए एक array adapter ए क क selection events क respond क न क ए OnItemSelectedListener interface क क Defining android spinners Android spinners क आप XML layout file define क क ए आप <Spinner> element define क element क basic attribute view elements  android:id - attribute क आप spinner क id define क  android:layout_width - attribute क आप spinner क width define क
  • 70. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com  android:layout_height - attribute क आप spinner क height न क Example <Spinner android:id="@+id/yrspinnerid" android:layout_width="width-of-spinner" android:layout_height="height-of-spinner" /> Creating spinner items list Spinners क items list एक string resource file आप ए क क क ए आप एक string array ए क क ए आप <resources> element क <resources> element क आप <string-array> sub-element define क <string-array> element क name attribute आप array क न define क क <string- array> element <item> sub element define क औ items क आप element define क Example <resources> <string-array name="yrstringarray"> <item>Item 1</item> <item>Item 2</item> <item>Item 3</item> </string-array> </resources>
  • 71. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Items क ए क न क array औ spinner क connect क न क ए आप एक array adapter ए क क ए प आप एक spinner object create क औ क reference XML layout file आपन spinner define क क ऐ आप spinner क id क क Example Spinner yrspinner = (Spinner) findViewById(R.id.yrspinnerid); क आप ArrayAdapter क object create क Example ArrayAdapter<CharSequence> yrAdapter = new ArrayAdapter(); क string resource file आप ArrayAdapter directly ए न क क क ए आप ArrayAdapter क object प createFromResource() method क क आप current context, string array औ items क layout प क Example yrAdapter.createFromResource(this,R.array.yrstringarray,android.R.layout.simple_spinner_it em); क layout आप items display क क न set क क ए आप adapter object प setDropDownViewResource() method call औ layout आप क न pass क Example yrAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  • 72. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com क आप adapter क spinner क apply क Example yrspinner.setAdapter(yrAdapter); क आप क क ई item select क न प action न define क Responding to item selection क ई item select क ऐ situation आप क action न action आप onItemSelected() method न क method क आप Activity क inherit क न न क onItemSelectedListener interface क implement क न ए method आप AndroidView, View, position औ spinner क id प क Example public void onItemSelected (AdapterView av, View view, int posi, long id ) { // handle what you want to do here } आप क select न क ऐ situation आप क ई action क क ए आपक onNothingSelected() method क define क न Example public void onNothingSelected(AdapterView av) { // handle what you want to do here }
  • 73. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 19 Search Interface This chapter covers  Introduction  Creating search interface  Adding custom suggestions Introduction to android search interface Searching क ए क न क एक important feature क आप क आपक application क particular information service क ए search क क आपक क ए पन ए क न search interface add क न Android applications आप search interface 2 add क क एक आप पन application क top area search dialog add क क क आप एक search widget क पन application embed क क Android system search interface implement क न आपक क search queries क ऐ activity क प searching perform क आप search क आप suggestions provide क क Android क search framework आपक application data search क न क ए API provide न क आपक पन application क एक API choose क न Creating android search interface क न आपक प android search interface आप 2 implement क क प आप एक search dialog implement क क औ आप search widget क embed क क
  • 74. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com न situation search query आपक application क क specific activity क प आ प न न क क न Search dialog एक UI (User Interface) component user search option प click क activate औ search dialog क आप ऊप ई picture क Searches क handle क न क ए आपक एक activity specify क न query submit क query activity क प आपन specify क Search widget क आप layout क क Search widget SearchView क object search widget एक text box क कन आप configure क क क queries एक particular activity क deliver क क query submit क android system us query क intent save क औ intent क आपक application क activity क आपन searches handle क न क ए specify क पन application searching capability add क न क ए आपक 3 क प  प एक XML file क आप search dialog क settings क configure क  क आप एक activity create क user क queries क handle क  क आपक एक search interface क आ क क UI provide क आ न steps क detail - XML file एक XML file आप <searchable> element declare क <searchable> element क एक attribute android : label आप application क name specify क file क आप क ई न क कन क most common न searchable Example <searchable xmlns:android="http://schemas.android.com/apk/res/android" android:label="application_name">
  • 75. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com </searchable> Activity to handle searches Searches क handle क न activity एक ऐ activity user क queries क handle क औ results क search queries intent क activity क प क क intent क action ACTION_SEARCH Android system क ए क android system searches क handle क न activity क identify क क ए आपक activity क AndroidManifest.xml file define क न क न - Example <activity android:name=".your_search_handler_activity"> <intent-filter> <action android:name="android.intent.action.SEARCH"> </intent-filter> <meta-data android:name="android.app.searchable" android:resource="@xml/ your configuration file with searchable element"> </activity> ऊप ए 2 important एक क <intent-filter> element क android:action attribute action SEARCH define क <meta-data> element क android:name attribute आप android.app.searchable औ android:resource attribute configuration XML file क URL आपन <searchable> element declare क आप searches क handle क न activity onCreate() method क override क क getIntent() intent क क औ intent क compare क क search action intent
  • 76. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com क intent search action आप query क extract क औ एक query क न variable create क क store क Intent query extract क न क ए आप getStringExtra() क एक आप query extract क query क न प आपक पन application data search क न औ result क न Data search क न application क क आपक data SQLite database आप आ न android.database.sqlite API क ए search क क औ आपक data online stored user क data connection wifi क आ क Search results क ListView क न क आप setListAdapter क data adapter क bound क क औ results क क
  • 77. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 20 Android file system This chapter covers  Introduction  Core directories of android file system  Sharing files Introduction to android file system Android file system न directories आ न क purpose न क directories ऐ नक न android system क न क क Android क file system device related data औ user क data User क files core file system क corrupt न क क ए user files औ system files क directories क Android system files क unauthorized access न क permissions provide क क ऐ device run क न क ए necessary ऐ files क आप delete न क क ए ऐ files क ए read permission User files क ए complete permission आप read क क औ file क modify क क औ delete क क Android file system एक hierarchy क represent क Android file system directories कन न क आपक न क न क necessary directories नक आपक ऊ
  • 78. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Directories of android file system /Boot - directory tools available android system क start न क ए necessary directory kernel औ ram-disk directory क न आपक device start न क directory क delete क आपक device क start न क क आप प न /System - directory आपक प android operating system directory android क graphical user interface application आपक device प installed क ई आ directory directory क delete क आपक phone on कन android operating system न ए आप device क न क क /Recovery - directory backup क ए न आपक system क boot directory corrupt आपक प एक क प directory क आप pure system क recover क क /Data - directory क data store क directory user क images, files, videos औ contacts User android applications install क directory store क आप पन devices क reset क directory प /Cache - directory files औ applications आप frequently क directory क format क न user औ system data प क ई क न प directory क format क क आप RAM memory क क /Misc - directory क settings store क device क personalize क Sharing files कई एक application application क files share क न क आ क क ए आप पन क क क ई picture न picture gallery application whats-app application क picture क आप पन application क क file क क क File क एक application application क प न क ए आपक पन application क configure क न आप files क content URI क form क
  • 79. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Android FileProvider class content URI generate क क application क files क न क क क आप files क send न क क नक URI (files URL ) क क औ application क क क ए file क access क न क permission Send क न files क URL क न safe आप receive क न application क uniquely identify क क औ application क औ क ई application files क access न क क Content URI क पन आप expire FileProvider क getUriForFile() method क file क URI generate क न क ए क method आप file क न argument क प क औ function आपक file क URI return क Files क न क ए आपक पन application FileProvider क define क न ऐ आप FileProvider क entry AndroidManifest.xml file क क क क क ए आप <provider> element क element क 4 attributes -  andriod:name - आप FileProvider क URI  android:authorities - आप authority क न आप FileProvider क generated content URI क ए क न ex. yrPackage.fileprovider.  android:grantUriPermission - attribute क आप set क  android:exported - attribute क आप initially false set क Ex. <provider android:name="URI-of-file-provider-URI" android:authorities="name-Of-Authority" android:grantUriPermission="true" android:exported="false"> <meta-data> element <provider> element क एक sub element element एक XML file क define क आप क न क न directories share क न element क 2 attributes -  android:name - आप FileProvider क paths क URI  android:resource - आप XML file क URI
  • 80. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Ex. <meta-data android:name="file-provider-paths-URI" resource="name-of-XML-file" > XML file directories आप share क न define क न क आ न क ए आप <paths> element क element क एक sub element <files-path>. element आप directory क path element क 2 attribute name औ path. Ex. <paths> <files-path path ="yourDirectory/" name="nameOfFile"> </paths> आप पन class क ए file provider define क applications आन requests क आप handle क क ऐ क न क एक क क आप एक activity create क file selection interface provide क औ files select क ए आप selection प action क कन action न प आपक application क access permissions न ए
  • 81. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com Chapter 21 Storage system This chapter covers  Introduction  Storage options o Shared preferences o Internal storage o External storage Introduction to Android storage system Android system क क न क ए options provide क आप क न option choose क आप प depend क आपक data primitive आप shared preferences क क आपक data private आप internal storage store क क आपक application क ए database store क न आप SQLite database क क औ आप network connection क क cloud storage पन data क क क android system न storage option provide क कन पन application क ए storage option choose क न necessary क ए आपक पन project ए members क advice न ए आ different android storage options क detail नन क क Shared preferences SharedPreferences एक आपक एक provide क आप key value क pair क primitive values (int , boolean, char, float, strings) store क क
  • 82. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com आप shared preferences store क different user sessions available SharedPreferences क object क न क ए आपक प 2 options एक आप getSharedPreferences() method क क क method आपक क न ए आप preferences files ए क न option क आप getPreferences() क क method क आप एक preference file ए क क प आप SharedPreferences क object ए क आप variable क न औ initial value प क SharedPreferences myObj = new SharedPreferences(variable_name, initial-value); SharedPreferences क object ए क न क value store क न क ए आपक SharedPreferences.Editor क ऑ ए क न ऐ आप SharedPreferences क object प edit() क क क क क SharedPreferences.Editor ediObj = myObj.edit(); क values store क न क ए methods क putBoolean() औ putString() आ न methods क आप editor object प क क ediObj.putString("name",value); क आपक values क commit क न ediObj.commit(); Values क read क न क ए आप SharedPreferences क ऑ प methods क क क क getBoolean() औ getString() आ Internal storage आप files क device क internal memory save क क files internal memory saved private , applications access न क क आपक application क remove क files remove क file क internal storage save क न क ए आपक openFileOutput() method क क न method FileOutputStream class क object return क FileOutputStream data क file क through output क न क ए क एक stream क represent
  • 83. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com क openFileOutput() आप file क न औ mode pass क File क 4 mode क  MODE_PRIVATE - default mode mode file private  MODE_APPEND - प क ए न क file प न file क data क आ add  MODE_WORLD_READABLE - क files create क न security क point of view risky क क क ई application access क क  MODE_WORLD_WRITABLE - क file क क ई application modify क क FileOutputStream क object प न क आप प write() क क औ file क save क क आप close method call क क output stream close क Ex. String name="yrName"; FileOutputStream obj = openFileOutput(fileName,Context.MODE_PRIVATE); obj.write(name.getBytes()); // write data in form of byte only. obj.close(); // closing stream क internal storage files क read क न क ए आपक openFileInput() method क क न method FileInputStream क object return क method आप file क न प क क आप FileInputStream क object प read() क क क file क read क Ex. FileInputStream obj = openFileInput(fileName); obj.read(); obj.close(); External storage android device capability क आप external memory add क क memory removable क क SD card आ औ non removable क कई internal memory क limit क क external memory क क External
  • 84. ©www.besthinditutorilas.com You can download this eBook from www.besthinditutorials.com storage save न classes world readable mode क औ आप पन device क PC connect क न files क क ई modify क क आपक application external storage files save क न क ए क 2 क system permissions क आ क  READ_EXTERNAL_STORAGE - permission external storage files क read क न क ए  WRITE_EXTERNAL_STORAGE - permission external storage files save क न क ए Ex. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> External storage क ई क क न प आपक memory क media status क क न ए क क external storage क ई file न readable files External storage क status check क न क ए आप getExternalStorageState() method क क क method आपक files क states return क न आप क notify क क आप files क public न आप public directories save क क क Music, Pictures आ External storage files save क न आ न क ए आप एक file ऑ ए क औ file क न औ public directory क न प क Ex. File myFile = newFile(DIRECTORY_PUBLIC, fileName); External storage save क files क आप internal storage क files क न methods open औ edit क क