Professional Documents
Culture Documents
Marathi Book On Mobile Application Development - 22617 (Learning Material)
Marathi Book On Mobile Application Development - 22617 (Learning Material)
१ १ - ११
(Android and its tools)
२ Android १२-३३
(Installation and Configuration Of Android)
४ ६२-१०५
(Designing User Interface With View)
५ ह १०६-२०२
(Activity and Multimedia with Databases)
६ २०३-२५५
(Security and Application Deployment)
Mobile Application Development (22617) (२२६१७)
घटक १
अँडरॉइड
आकृतीिह
(display)
(Android Inc)
२००५
२०१३
1 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Motorol Q ८०
क API
- १ .० १ २३ िप्टेंबर २००८
- १ .१ २ ९ फेब्रुवारी २००९
2 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
नौगट(Nougat) ७ .० – ७ .१ २ ४ – २५ २२ ऑगस्ट २० १६
Q १० .० २९ ३ िप्टेंबर २०१९
११ ११ .० ३० ८ िप्टेंबर २०२०
ट १
१
२
३
१ क –
२
-
ट -
3 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क १.१
– : - -
-
- -
-
-
ट :
4 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
३.
कट:
कट
१.२
कट
.
क Device diversity):
क (Customization)
5 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
ट (Rooting)
(Android Community)
क Global partnership)
१५ (Google
१.२.१
-
-
-
-
6 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
HTML५ CSS३
-
२D/३
ट ट
१.३ क क क
२ १० ५ ८
३ (Linux ) GNU C Librar २ ७
१ ५
२. (Android Studio )
envoiurnment)
ट कट क टक
-
JAVA_HOME
7 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
‗ ‖ ‗‖‘
‗ ‖ ‗‖‘ .
‗ ‖ ‗‖‘
‗ ‖ ‗‖‘
(Android Studio)
Eclipse IDE(
१.४ कट
१.
२. ( )
३.
४.
५.
8 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क १.२ कट
१. क
क
9 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
P oce
ट क क
(Driver Model):
२. ट
.
- - ‘
’
SQLit
-
३. ट
10 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
४. क
.
५. क क
(Bibliography)
https://www.geeksforgeeks.org/android-architecture/
https://www.tutorialspoint.com/android/android_overview.htm
11 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
घटक २
Android क
Installation and Configuration Of Android
६
(Course Outcome):
➢ IDE
➢ .
➢ .
➢
➢ .
SDK
. Google ,
SDK . SDK ,
. SDK
12 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
(SDK)
, .
SDK .
ADT Bundle .
SDK ADT (Android Developer
SDK ट
SDK
. SDK , .
ट ट
SDK : .
.
( ) .
, .
.
, , , , .
- . ,
13 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
,
.AVD .
टक
क २.३.१
14 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क २.३.२
3: , .
Pixel 2 XL . , .
15 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क २.३.३
4: , . ,
क २.३.४
5: , R ( 11) .
, .
, , .
16 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क २.३.५
6: , , Finish .
क २.३.६
17 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क २.३ .७
7: , AVD
. AVD , ,
“ Y ”
Finish AVD .
8: ,
२ .४ ट Emulators
API
.
, .
18 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
. . .dex
Dalvik VM . dex .
क २.५.१
javac java .
dx .dex . -
(aapt) .
Srno क
..
19 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
VM VM
.
3 .jar .apk
. .
The executable file for the device is .jar The executable file for the device is
4 JVM
Java bytecode
. , DEX (dx )
.apk
Java source code is compiled into Java .
bytecode format(.class file) that further Source code files are first of all
translates into machine code. compiled into Java bytecode format
20 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
5 - VM - VM
CPU
. .
JVM
. DVM
२.६ SDK क क
21 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Google IDE
. IntelliJ IDEA , Apache
. .
● .
● TV Wear .
● - .
● .
● .
● APK .
● C++ NDK .
1. क (System Requirements)
Google , . .
,
4 GB RAM , 8 GB RAM
1280 x 800
2. क
22 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
1 -
२.६.१
3 , . ,
1 ( ,
). , -Next
23 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
२.६.२
2 ,
२.६.३
3 , .
24 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
२.६.४
4 , SDK . , .
२.६.५
25 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
२.६.६
6 ,
२.६.७
7 , .
26 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
२.६.८
8 ,
२.६.९
27 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
SDK
, SDK .
4. ट
1 , /
–
२.६.१०
. 2
. sdk , . ,
. .
28 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
२.६.११
, . ,
२.६.१२
29 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
. ,
. .
२.६.१३
, . .
, .
२.६.१४
30 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
, . .
२.६.१५
5. SDK घटक क .
SDK
SDK, ,
. -
API
OS
SDK ( ) . SDK
. . Lollipop SDK ,
Lollipop . ,
31 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
SDK .
, ,
, SDK .
SDK
SDK -
.
, Appearance
२.६.१६
, .
. , ,
.
32 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
२.६.१७
(Bibliography)
https://www.geeksforgeeks.org/android-architecture/
https://www.javatpoint.com/dalvik-virtual-machine
https://source.android.com/docs/setup/create/avd
https://developer.android.com/studio/install
33 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
(Course Outcome): गु ण ८
विषय वनष्पत्ती (Course Outcome):
घटक आसण लेआउट वापरून ररच यूजर इं टरफेि सवकसित करा. ( Develop Rich user
सदलेल्या सनदे सशकेची रचना िंबंसधत िादृश्याने स्पष्ट करा.(Explain with relevent analogy the given
directory Structure.)
सदलेले ररच UI घटक वापरण्याच्या चरणां चे वणिन करा. (Describe the steps to use the given
Android rich UI Componets.)
सदलेल्या लेआउटचा िकार वापरण्यािाठी चरणां चे वणिन करा.( Describe the steps to use the given type
of layout.)
ऍप्लिकेशन घटक हे ऍप्लिकेशनचे आवश्यक सबप्लडंग ब्लॉक्स आहे त. हे घटक ऍप्लिकेशन मॅसनफेस्ट फाइल
AndroidManifest.xml द्वारे िहज जोडलेले आहे त जे ऍप्लिकेशनच्या ित्येक घटकाचे आसण ते किे परस्परिंवाद
करतात याचे वणिन करतात.ज्या क्लािला इतरां च्या गुणधमाा चा वारिा समोतो तो उपक्लाि ्युतुपन्न क क्लाि, चाइड क्लाि)
म्हणून ओोखला जातो आसण ज्या वगाि च्या गुणधमाा ना वारिा समोतो तो िुपरक्लाि ्बेि क्लाि, पॅरेंट क्लाि) म्हणून
ओोखला जातो.
अॅप्लिविटी (Activity): अॅप्लक्टसवटी हे एक एकमेक यूजर इं टरफेि िसहत सिं गल स्क्रीन दशिवते. ते वापरकत्याि शी िंवाद
स्थासपत करण्याच्या लक्षात घेतले जाते.
सेि (Service): िेवा हे अॅ प्लक्टसवटीच्या बाहे रील चालू ठे वलेले काये करते , जी लॉन्ग रसनंग ऑपरे शन्सिाठी वापरली जाते.
34 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
प्रदशशन (Broadcast Receiver): ब्रॉडकास्ट ररसिव्हर हे एवढे िमुख निताना प्लस्थतीत ब्रॉडकास्ट मेिेज िु सनसित करते
आसण त्यां चे उत्तर दे ते.
प्रद न (Content Provider): कंटें ट िोव्हायडर हे ऍप्लिकेशनमध्ये अिलेल्या डे टाचे इतर ऍप्लिकेशनमध्ये िामासयक
करण्याची क्षमता पुरवते.
फ्रैग्मेंट (Fragment): फ्रैग्मेंट हे अॅप्लक्टसवटीमध्ये आपली स्थाने ठरसवणारे आहे , ज्यामुोे मधुर आसण मॉड्युलर सडझाइन
इां टेंट (Intent): इं टेंट्ि अॅप्लिकेशनच्या सवभागां मध्ये िंवाद स्थासपत करण्याचा माध्यम पुरवते , ज्यामुोे एप्लक्टसवटीि,
बन िट (Layouts): आं डरॉइड ऍप्लिकेशनमध्ये UI तयार करण्यािाठी वापरलेले लेआउट् ि, ज्यामुोे आपली UI िंरचना
िुसनसित करू शकतो.
सांस धन (Resources): ऍप्लिकेशनमध्ये वापरलेले िं िाधन, ज्यामुोे त्यातील सचरे, प्लस्टरंग्स, आसण इतर आवश्यक मासहती
एकाच ऍप्लिकेशनमध्ये ही िवि कॉम्पोनेन्ट्ि समसितपणे काम करतात आसण वापरकत्याा ना िुिभावी आसण उपयुक्त
१.अॅप्लिविटी (Activities)
"अॅप्लक्टसवटी ्Activity)" अॅप्लिकेशनमध्ये एक महत्त्वपूणि कंपोनेंट आहे , ज्याच्या माध्यमातून वापरकताि िंवाद
स्थासपत करतो. यामुोे एप्लक्टसवटी हे एक अनुियोगाचे िवेशद्वार ्entry point) अिते. येथे त्याच्या िंरचनेची महत्त्वाची
मासहती आहे :
आिृत्ती (Lifecycle): एप्लक्टसवटीने सवसवध आवृत्तीची प्लस्थती दशिवते , ज्यामुोे ती कधीही िसहृय सकंवा सनप्लस्क्रय होते.
यामुोे तुमच्या अॅप्लिकेशनला त्याचे सवसवध चरररे होतात, जिे की िुरुवातीला, िसहृय, बंद, सकंवा पुनरारं भ.
UI तय र करणे (UI Creation): एप्लक्टसवटीमध्ये वापरकत्याा िाठी दृश्य कंपोनेंट्ि तयार करणे , त्यां ची स्थाने ठरवणे आसण
त्यां ना सवन्याि करणे.
यूजरसोबत तय र करणे (Interaction with User): एप्लक्टसवटीने वापरकत्याा िोबत िंवाद स्थासपत करण्यािाठी इवेंट्ि
िुरू करते , जिे की बटनसकंवा मेनू वापरकत्याा िोबत एक्शन िुरू करणे.
इां टेंट्स (Intents): एप्लक्टसवटीने इं टेंट्ि वापरून इतर एप्लक्टसवटी सकंवा िेवा िुरू करू शकते.
35 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
मेवनफेस्ट फ इलमध्ये म वहती (Manifest File Information): मॅसनफेस्ट फाइलमध्ये एप्लक्टसवटीिाठी मुख्य मासहती
दे णे, जिे की त्याचं नाव, इं टेंट सफल्टर, आसण िुरू केलेल्या इं टेंटिाठी वणिन.
स्थ नीय डे ट सांग्रहण (Local Data Storage): एप्लक्टसवटीने स्थानीय डे टाबेि सकंवा इतर स्थानीय िं ग्रहणां मध्ये डे टा
िंग्रसहत करण्यािाठी कोड िमासवष्ट करू शकते.
फ्रैग्मेंट्स सोडिणे (Managing Fragments): एप्लक्टसवटीमध्ये फ्रैग्मेंट्ि वापरकताा िोबत मधुर िंवाद स्थासपत
स्क्रीन वकांि लेआउट बदलणे (Changing Screen or Layout): सवसवध पररप्लस्थतीत एप्लक्टसवटीने स्क्रीन सकंवा
एप्लक्टसवटी म्हणजेच अॅप्लिकेशनच्या वापरकत्याा िोबत िंवाद स्थासपत करणारी मुख्य यूजर इं टरफेि पृष्ठभूमी आहे . ती एक
मोबाइल अॅप्लिकेशन सवकसित करण्यािाठी वापरकताि इं टरफेििह सिंगल स्क्रीनचे िसतसनसधत्व करते , थोडक्यात
सहृयाकलाप स्क्रीनवर सहृया करते. उदाहरणाथि , ईमेल अॅप्लिकेशनमध्ये नवीन ईमेलची िूची दाखवणारी एक अॅप्लक्टप्लव्हटी,
ईमेल तयार करण्यािाठी दु िरी अॅप्लक्टप्लव्हटी आसण ईमेल वाचण्यािाठी दु िरी अॅप्लक्टप्लव्हटी अिू शकते. जर एखाद्या
अॅप्लिकेशनमध्ये एकापेक्षा जास्त सहृयाकलाप अितील, तर त्यापैकी एक अॅप्लिकेशन लॉन्च केल्यावर िादर केलेल्या
सहृयाकलाप म्हणून सचन्ां सकत केले जावे.
अॅप्लिकेशनमध्ये एप्लक्टसवटी एक महत्त्वाचं घटक आहे , ज्यामुोे वापरकताा ना अॅप्लिकेशनमध्ये नेप्लव्हगेट करण्यात
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
36 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setContentView(R.layout.activity_main);
// इतर एप्लक्टसवटी लाइफिायिल इवेंट्ि ्जिे onCreate, onStart, onResume, onPause, onStop, onDestroy)
@Override
super.onPause();
}}
इतक्यात नकारात्मकी पाहूनही, आपली एप्लक्टसवटी चां गली दृष्टीने स्थासपत केली जाते , जी वापरकताा ना आपल्या
अॅप्लिकेशनमध्ये नेप्लव्हगेट करण्यात मदत करते.
२.सेि (Services)
िेवा हा एक घटक आहे जो दीघिकाो चालणाऱ्या ऑपरे शन्स करण्यािाठी पार्श्िभूमीत चालतो. उदाहरणाथि , वापरकताि
वेगळ्या अॅप्लिकेशनमध्ये अिताना िेवा पार्श्िभूमीत िंगीत िे करू शकते सकं वा एखाद्या सहृयाकलापािह वापरकत्याि च्या
बॅकग्राऊंड िोिेिेि ्Background Processes): िेवां ची एक मुख्य वापर म्हणजे च लॉन्ग रसनंग िसहृया िुरू करणे आहे ,
ज्यामुोे वापरकताि ऍप्लिकेशन बाहे रीला जाऊनिुद्धा त्याच्या ऍप्लिकेशनमध्ये काम करवू शकतो.
37 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
समसडया स्टर ीसमंग ्Media Streaming): िेवां चा वापर ध्वसन, प्लव्हसडओ सकंवा इतर समसडया डे टा स्टर ीसमंगिाठी केला जातो.
उदाहरणाथि , इं टरनेट रे सडयो ऍप्लिकेशन.
नेटवकि कॉल्स ्Network Calls): वापरकताि ऍप्लिकेशनमध्ये िेवेचे उपयोग नेटवकि कॉल्सिाठी होते , ज्यामुोे दू रस्थ
िेवां िह िंवाद स्थासपत करण्यात मदत करते.
पुष नोसटसफकेशन्स ्Push Notifications): िेवेचे वापर पुष नोसटसफकेशन स्थासपत करण्यात येते, ज्यामुोे वापरकत्याा ना
अवकाशी डे टा सिं हृोनायझ ्Background Data Sync): िे वां मध्ये डे टा सिंहृोनायझ करणे , ज्यामुोे अवकाशी
िंग्रसहत डे टा िबंधन ्Data Management): िेवें डे टाचे िंग्रहण करून वापरकत्याा ना एकाच स्थानी इतर ऍप्लिकेशनिह
िामासयक करण्याची क्षमता पुरवतात.
िेवां चे उपयोग अने क िकारे केले जाते आसण त्यां मध्ये काही िेवा स्थासनक ऍप्लिकेशनिाठी अितात त्यातील िेवा स्थासनक
डे टा अॅक्सेििाठी वापरले जाते. आपल्याला वापरकताि इं टरफेििह वापरकताा िाठी एक आपल्याच्या ऍप्लिकेशनमध्ये
िेवां ना िुरु करण्याची क्षमता पुरसवणारी िंिेषण एका महत्त्वाच्या घटकाची मान्यता आहे .
िेवा ्Services) अॅप्लिकेशनमध्ये लॉन्ग रसनं ग ऑपरे शन्सिाठी वापरली जाते. या िेवेच्या उपयोगां िाठी Marathi
@Override
// यसद िेवेची बाइं सडं ग आवडते तर तु म्ही इथे IBinder िदान करू शकता.
38 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
return null;
@Override
return START_STICKY;
@Override
super.onDestroy();
}}
@Override
// डे टा सिंहृोनायझ सकंवा इतर लॉसजक अिल्याि त्या तुम्हाला येथे सलहावं शकतं.
return START_STICKY;
39 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
super.onDestroy();
// बाइं सडं ग केल्यानंतर तुम्ही काही परत दे ऊ इप्लिता अिल्याि त्यािाठी आणखी लॉसजक अिणे शकते.
return null;
}}
सेिेची शुरूआत आवण बांद करणे (Starting and Stopping the Service):
context.startService(serviceIntent);
context.stopService(serviceIntent);
अशा िकारे , तुम्ही आपली िेवा िुरू करू शकता आसण बंद करू शकता. जर तुम्ही िेवेच्या द्वारे सकंवा त्याच्या िाथी
आपली ऍप्लिकेशनिाठी दु लिक्ष ऑपरे शन्स काढण्याची इिा निली तर तु म्ही startService() आसण stopService()
वापरू शकता.
ब्रॉडकास्ट ररिीव्हिि इतर ऍप्लिकेशन्स सकंवा सिस्टमवरून ििाररत िंदेशां ना िसतिाद दे तात. उदाहरणाथि , ॲप्लिकेशन
इतर ऍप्लिकेशन्सना हे कोवण्यािाठी ब्रॉडकास्ट िुरू करू शकतात की काही डे टा सडव्हाइिवर डाउनलोड केला गेला
40 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
आहे आसण त्यां च्यािाठी वापरण्यािाठी उपलब्ध आहे , म्हणून हा ब्रॉडकास्ट ररिीव्हर आहे जो या िंिेषणात अडथोा
आणेल आसण योग्य कारवाई िुरू करे ल.
ब्रॉडकास्ट ररिीव्हर ब्रॉडकास्ट ररिीव्हर क्लािच्या िबक्लाि म्हणून अं मलात आणला जातो आसण ित्ये क िंदेश इं टेंट
ऑब्जेक्ट म्हणून ििाररत केला जातो.
ब्रॉडकास्ट ररिीव्हर ्Broadcast Receiver) अॅप्लिकेशनमध्ये एक महत्त्वाचं घटक आहे , ज्यामुोे ऍप्लिकेशनमध्ये
घडणाऱ्या सवसशष्ट घटनां चे िुचना समोते. त्याचे मराठीतून एक उदाहरण दे खील सदले जाते.
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
@Override
// ब्रॉडकास्ट िुचना समोल्यानंतर काही काम करण्यािाठी onReceive वापरा. उदाहरणाथि , एक "बॅटरी लाईफ लो
41 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
} }
}}
ब्रॉडकास्ट ररिीव्हरचे उपयोग केल्यानंतर, तुम्ही तो तुमच्या मनापािून लायब्ररीमध्ये तो नोंदवून, त्याची नोंदणी करू शकता.
त्यामुोे तो ऍप्लिकेशन चालसवण्यात येईल आसण त्याच्या ब्रॉडकास्ट िुचनां मध्ये तुम्हाला वाचण्यात येईल <!--
<receiver
android:name=".MyBroadcastReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<!-- इतर आवश्यक ब्रॉडकास्ट िुचनां िाठी इथे तुमची नोंदणी करा -->
</intent-filter>
</receiver>
. उपरी कोडमध्ये , तुम्ही MyBroadcastReceiver नावाचं ब्रॉडकास्ट ररिीव्हर तयार केलं आहे . त्याचे काम onReceive
सवधीमध्ये केलं जातं. त्याचे एक उदाहरण म्हणून , तुम्ही बॅटरी लाईफ लो आहे अिल्याि वापरकताा ना िूसचत करण्यािाठी
िामग्री िदाता घटक सवनंतीनुिार एका अनुियोगावरून इतरां ना डे टा पुरवतो. अशा सवनंत्या ContentResolver वगाि च्या
पद्धती ंद्वारे हाताोल्या जातात. डे टा फाइल सिस्टीममध्ये , डे टाबेिमध्ये सकंवा इतरर पूणिपणे िंग्रसहत केला जाऊ शकतो.
42 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
िामग्री िदाता िामग्री िदाता वगाि चा उपवगि म्हणून कायाि प्लित केला जातो आसण त्याने API चा मानक िंच लागू करणे
आवश्यक आहे जे इतर अनुियोगां ना युतवहार करण्याि िक्षम करते. िामग्री िदाते ्Content Providers)
अॅप्लिकेशनमध्ये एक महत्त्वाचं घटक आहे , ज्यामुोे ऍप्लिकेशन्स एकमेकां चे डे टा िामासयक करू शकतात. त्यां चे मुख्य
कायि इतर अॅप्लिकेशन्सिोबत डे टा िामासयक करणे आहे , ज्यामुोे ते अॅप्लिकेशन्स एकमेकां ना डे टािह िंवाद स्थासपत
करू शकतात.
import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;
43 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
static {
@Override
return true;
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String
sortOrder) {
// डे टा िदान करण्यािाठी query मेथड वापरा. तुम्ही इथे तुमचे डे टाबेि क्वेरीि सलहू शकता.
return null;
@Override
return null;
@Override
44 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
// डे टा अंतभूित करण्यािाठी insert मेथड वापरा. तुम्ही इथे तुमचे डे टाबेिमध्ये डे टा इन्झेक्ट करू शकता.
return null;
@Override
// डे टा हटसवण्यािाठी delete मेथड वापरा. तुम्ही इथे तुमचे डे टाबेिमध्ये डे टा हटवू शकता.
return 0;
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
// डे टा अद्यसतत करण्यािाठी update मेथड वापरा. तुम्ही इथे तुमचे डे टाबेिमध्ये डे टा अद्यसतत करू शकता.
return 0;
}}
िामग्री िदाते तयार केल्यानंतर, तुम्ही तो AndroidManifest.xml फाइलमध्ये नोंदवून घेऊ शकता आसण इतर
अॅप्लिकेशन्स तु मच्या िामग्रीिह िंवाद स्थासपत करू शकता.
<provider
android:name=".MyContentProvider"
android:authorities="com.example.myapp.provider"
android:exported="false" />
45 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
उपरील कोडमध्ये , MyContentProvider नावाचं िामग्री िदाते तयार केलं आहे . त्याचे मुख्य काम डे टा िदान करणे आहे .
तुम्ही इथे तुमचे डे टाबेि क्वेरीि वापरू शकता, आसण आपली िामग्री िदाते
अवतररक्त घटक
लेआउट (Layouts): लेआउटिाठी सवसवध लेआउट क्लािेि वापरतो, ज्यातील िामासयक व युतवप्लस्थत UI घटक
RelativeLayout (ररलेसटवलेआउट): घटके एकमेकां ि अथवा मूो आवकाशां सकंवा स्थानां तर करतो.
सवजेट / दृश्य ्Widgets/Views): हे त्या वैयप्लक्तक UI कंपोनेंटि आहे त, ज्यामुोे वापरकते िंवाद स्थासपत करू शकतो.
िामान्य सवजेट्ि म्हणजेच:
RecyclerView (रीिायक्लरयुतू): स्क्रॉल करण्याची सकंमत आहे सकंवा सग्रडिाठी दशिसवण्याची सकंमत.
फ्रग्मेंट ्Fragment): फ्रग्में ट हे एप्लक्टसवटीचे एक भाग दशिवतात. ते िामान्यत: लचील आसण मॉड्युलर UI सडझाइन तयार
करण्यात वापरते.
स्त्रोते ्Resources): हे लेआउट, प्लस्टरंग, सडमेंशन, रं ग आसण इतर िंिाधनां ची िामग्रीिाठी आहे , ज्यामुोे कोडपािून
िसतस्थानां तर वापरकत्याि ला दशिसवता येते.
46 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
डरॉयबल स्त्रोते ्Drawable Resources): इमेज, आकारे आसण इतर डरॉयबल पदाथाा िाठी वापरतात.
मासहती दे ते, ज्यात एप्लक्टसवटीज, िसवििेि, परवाहने आसण इतर कॉप्लिगरे शनिह िंबंसधत मासहती आहे .
सनदे सशका िंरचना कोणत्याही िकल्पाचा पाया आहे . हे एका कंटे नरिारखे कायि करते ज्यामध्ये आवश्यक
तकिशास्त्र, िसतमा, िानुकूलन त्याच्या वास्तसवक स्वरूपात अिते. एखाद्या िकल्पाच्या सनसमिती ्िंकलन) दरम्यान,
त्याला आवश्यक अिलेल्या ित्येक िकारच्या मालमत्ता शोधण्यािाठी या फोडरमध्ये पाहतो.
अँडरॉइड स्टु सडओ हा JetBrains िमुदायाने सवकसित केलेला असधकृत IDE (इं सटग्रेटेड डे व्हलपमेंट एन्व्हायनि मेंट) आहे जो
अॅप डे व्हलपमेंटिाठी Google द्वारे सवनामूल्य िदान केला जातो. अँडरॉइड आसकिटे क्चरचा िेटअप पू णि केल्यानंतर
आम्ही स्टु सडओमध्ये अँडरॉइड अॅप्लिकेशन तयार करू शकतो. आम्हाला ित्येक नमुना अनुियोगािाठी एक नवीन िकल्प
तयार करणे आवश्यक आहे आसण आम्हाला फोडरची रचना िमजली पासहजे. हे अिे सदिते:
47 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
१.LinearLayoutManager:
ि पर:
त्यामुोे तुम्ही आपली घड्याोातील घटके एक ओोीत स्थानां तररत करू शकता.
सवकिन क्षेरात, LinearLayout हा एक महत्त्वाचा लेआउट मॉड्यूल आहे , ज्याने सवचारायला आपल्याला आपल्या
घड्याोात एक िोपं स्थान दे ते. यामध्ये आपल्याला आपल्या घड्याोात आपल्या घड्याोात घड्याोाचं स्थान समोतं.
या एका उदाहरणात, एक LinearLayout आहे ज्यामध्ये आपल्या घड्याोात दोन बटणे अितील. एका
activity_main.xml नावाच्या फाइलमध्ये तुम्हाला या कोडमध्ये आपले आपले XML फाइल अिावे लागेल:
LinearLayout उद हरण
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
48 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<Button
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<Button
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
<Button
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="wrap_content"/>
</LinearLayout>
Ouput:
49 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
२. Absolute Layout
सवकिनातील Absolute Layout हे एक लेआउट मॅनेजर आहे , परं तु त्या वापरल्यामुोे अिा लेआउट तयार
करणे िवोत्तम नितं. Absolute Layout अनेक िमस्या दे ऊ शकतो आसण अन्य सडवाइिेििाठी िुिंगत नितो.
हे एक उदाहरण आहे की, तुम्ही एक Absolute Layout वापरता येथे किं आहे :
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="90dp"
android:layout_y="350dp"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
50 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="150dp"
android:layout_y="400dp"
android:text="Hello World"
android:textColor="@android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
</AbsoluteLayout>
३.Frame layout
51 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
अॅप्लिकेशन सवकिनातील एक इतर महत्त्वाचं लेआउट मॅनेजर आहे तो हा FrameLayout आहे . या लेआउटमध्ये ,
घटके ्जिे की बटणे , छायासचरे) एकमेकां चं वतिनीस्थान सकंवा प्लस्तसथस्थान घे तलं जातं. त्यामुोे , जेव्हा तुम्ही एक घटक
Example:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imgvw1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/flimg" />
<TextView
android:id="@+id/txtvw1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:background="#4C374A"
android:padding="10dp"
52 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:textColor="#FFFFFF"
android:textSize="20sp" />
<TextView
android:id="@+id/txtvw2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:background="#AA000000"
android:padding="10dp"
android:text="21/Aug/2017"
android:textColor="#FFFFFF"
android:textSize="18sp" />
Output:
वापरकताि िंगणकाच्या आकारानुिार, आसण त्यामुोे घटकां चं स्थान बदलून पहा. जर तु म्हाला एकमेकां चं स्थान वापरायचं
आहे तर FrameLayout एक चां गलं सवकल्प आहे . परं तु , त्याचं वापर केवो अवश्यक अिल्याि हे वापरा; अन्यथा
४.Table Layout:
सवकिनातील एक इतर महत्त्वाचं लेआउट मॅनेजर हे आहे "TableLayout". यातून तुम्ही एक टे बल स्वरुपाचं
लेआउट तयार करू शकता. टे बलमध्ये पंप्लक्तंतर, स्तंभ, आसण त्यां चं िमासवष्ट करण्याि िुगमता आहे .
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="UserId" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
54 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_weight="1"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Location" />
</TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
55 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_weight="1"
android:text="Hyderabad" />
</TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Guntur" />
</TableRow>
<TextView
56 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Guntur" />
</TableRow>
</TableLayout>
57 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Output:
५.Relative Layout:
घटके एकमेकां चं स्थान आसण िंबंध सनमाि ण करण्यािाठी वापरतात. तुम्ही या लेआउटमध्ये सवसवध घटकां ना एकमेकां चं
िंबंध सदल्याने स्थान आसण अिलेलं युताि तयार करू शकता.
खालील उदाहरणात तु म्ही RelativeLayout वापरून एक िाधा लेआउट तयार करू शकता:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button android:id="@+id/button1"
android:layout_width="wrap_content"
58 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"/>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
59 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"/>
<Button
android:id="@+id/button5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Middle Button"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
Output:
60 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
सांदभशसूची(Bibliography)
१ https://www.tutorialspoint.com/android/android_user_interface_layouts.htm
२ https://www.geeksforgeeks.org/components-android-application/
३ https://www.tutorialspoint.com/android/android_application_components.htm
४ https://www.tutlane.com/tutorial/android/android-application-components-activities-intents-
views-layouts-services
५ https://www.tutorialspoint.com/android/android_fragments.htm
६ https://info448-s17.github.io/lecture-notes/fragments.html
७ https://www.geeksforgeeks.org/android-ui-layouts/
61 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
गुण (12)
.
.
.
(Date Picker) (Time Picker)
४.१.
४.१.१ ट ट (TextView):
(TextView )
. (TextView ) ,
. (XML )
( ) .
XML TextView
<TextView android:id="@+id/simpleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Amrutvahini " />
ट ट (Attributes)
1. (id) : id .
.
<TextView android:id="@+id/simpleTextView"
62 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
2. ट (gravity):
(center_horizontal) .
<TextView android:id="@+id/simpleTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"/>
3. ट ट(text):
<TextView android:id="@+id/simpleTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Amrutvahini"
android:gravity="center_horizontal"/>
4. ट टक (textColor): textColor .
“― ” “― ” “― ” “― ” .
<TextView android:id="@+id/simpleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Amrutvahini"
android:layout_centerInParent="true"
android:textColor="#f00"/>
5. ट (textSize): textSize .
sp ( ) dp ( ) .
<TextView android:id="@+id/simpleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
63 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:textSize="40sp" />
6. ट (textStyle): textStyle .
(Bold), (italic) (normal) .
“|” .
<TextView android:id="@+id/simpleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
android:textStyle="bold|italic"/>
7. क (background): (background)
. (drawable) .
<TextView android:id="@+id/simpleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Amrutvahini "
android:layout_centerInParent="true"
android:textSize="40sp"
android:textStyle="bold|italic"
”―‖‖‖” >
<TextView android:id="@+id/simpleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Amrutvahini "
64 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_centerInParent="true"
android:textSize="40sp"
android:textStyle="bold|italic"
”―‖‖‖”
”‗‖ ”>
Example:
<TextView
android:id="@+id/simpleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AbhiAndroid"
android:layout_centerInParent="true"
android:textSize="40sp"
android:padding="10dp"
android:textColor="#fff"
android:background="#000"/>
क ४.१
65 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
४.१.२ टट ट (EditText)
, EditText .
.EditText TextView
. : EditText
.
(XML ) ( )
.
<EditText android:id="@+id/simpleEditText"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
ट ट (Attributes)
1. (id) : id .
.
< EditText android:id="@+id/simpleEditText"
android:layout_height="wrap_content"
android:layout_width="match_parent"/>
2. ट (gravity):
(left), (right), (centre),
android:layout_width="match_parent"
android:gravity="center_horizontal"/>
3. ट ट(text):
<EditText android:id="@+id/simpleEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Enter Email"
66 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
“ >
क ४.२
4. (hint): hint ,
.
.
<EditText android:id="@+id/simpleEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:hint="Enter Your Name Here" />
क ४.३
5. ट टक (textColor): textColor .
“― ” “― ” “― ” “― ” .
6. ट (textSize): textSize .
sp ( ) dp ( ) .
67 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
7. ट (textStyle): textStyle .
(Bold), (italic) (normal) .
“|” .
8. ट क textColorHint: textColorHint
.
9. क (background): (background)
. (drawable) .
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content" android:inputType="text"/>
क ४.४
<EditText android:layout_width="match_parent"
68 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ४.५
<EditText android:layout_width="match_parent"
क ४.६
४.१.३ ट (Button)
, .
. , , .
69 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
TextView . ,
.
<Button android:id="@+id/simpleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"/>
ट ट (Attributes)
1. (id) : id .
2. ट (gravity): (left), (right),
3. ट ट(text):
4. ट टक (textColor): textColor .
“― ” “― ” “― ” “― ” .
5. ट (textSize): textSize .
sp ( ) dp ( ) .
6. ट (textStyle): textStyle .
7. क (background): (background)
. (drawable) .
9. ट drawableBottom: drawableBottom
.
<Button android:id="@+id/simpleButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
70 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:background="#147D03"
android:text="Download Code"
android:textSize="20sp"
android:padding="15dp"
android:textStyle="bold|italic"
android:drawableBottom="@drawable/ic_launcher"/>
क ४.७
, .
४.१.४ ट ImageButton
, ImageButton .
.
.
ट ट (Attributes)
1. (id) : id .
2. src: src
.
android:src="@drawable/home" />
71 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ४.८
3. क (background): (background)
. (drawable) .
4. (padding): (padding) (left), (right), (top)
(bottom) .
5. ट paddingRight : .
6. paddingLeft : .
7. ट paddingTop : .
8. ट paddingBottom : .
<ImageButton android:id="@+id/simpleImageButton" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000"
android:src="@drawable/home"
android:padding="30dp"/>
क ४.९
72 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
४.१. ५ ट ट ToggleButton
, ToggleButton
/ .ToggleButton
, , , . / . .
ट ट (Attributes)
1. (id) : id
(center_horizontal) .
3. ट ट textOn And textOff:
/ .
/ textOff .
.
4. क Checked:
(Checked) .
(true or false) (true)
(false) . (false) .
5. (padding): (padding) (left), (right), (top)
(bottom) .
6. ट paddingRight : .
7. paddingLeft : .
8. ट paddingTop : .
9. ट paddingBottom : .
10. ट टक (textColor): textColor .
“― ” “― ” “― ” “― ” .
11. ट (textSize): textSize .
sp ( ) dp ( ) .
73 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
“|” .
android:checked="true"
android:layout_centerHorizontal="true"
android:textOff="Disable"
android:textOn="Enable"/>
क ४.१०
, RadioButton .
.
. RadioButon
74 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
.
.
ट ट (Attributes)
1. (id) : id
2. क Checked:
(Checked) .
.
3. ट ट(text):
4. ट टक (textColor): textColor .
“― ” “― ” “― ” “― ” .
5. ट (textSize): textSize
. sp ( ) dp ( ) .
6. ट (textStyle): textStyle .
(Bold), (italic) (normal) .
“|” .
7. ट drawableBottom: drawableBottom
.
8. ट drawableTop, ट drawableRight
drawableLeft: drawableBottom ,
.
Example of RadioButton
<RadioButton
android:id="@+id/simpleRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
75 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_centerHorizontal="true"
android:text="Radiobutton1" />
क ४.११
Example of RadioGroup
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/India"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:checked="true"
android:text="India"
android:textColor="#154"
android:textSize="20sp"
android:textStyle="bold" />
76 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<RadioButton
android:id="@+id/US"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:checked="false"
android:text="US"
android:textColor="#154"
android:textSize="20sp"
android:textStyle="bold" />
<RadioButton
android:id="@+id/aus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:checked="false"
android:text="Australlia"
android:textColor="#154"
android:textSize="20sp"
android:textStyle="bold" />
</RadioGroup>
77 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ४.१२
४.१ .७ क CheckBox
Android , .
/ .
CompoundButton .
ट ट (Attributes)
1. (id) : id
2. क Checked: (Checked)
. (true or false) (true)
(false) . (false)
.
3. ट ट(text):
4. ट टक (textColor): textColor .
“― ” “― ” “― ” “― ” .
5. ट (textSize): textSize .
sp ( ) dp ( ) .
78 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
6. ट (textStyle): textStyle .
(Bold), (italic) (normal) .
“|” .
7. ट drawableBottom: drawableBottom
.
8. ट drawableTop, ट drawableRight
drawableLeft: drawableBottom ,
.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<CheckBox
android:id="@+id/India"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:checked="true"
android:text="India"
android:textColor="#154"
android:textSize="20sp"
android:textStyle="bold" />
<CheckBox
android:id="@+id/US"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:checked="true"
79 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:text="US"
android:textColor="#154"
android:textSize="20sp"
android:textStyle="bold" />
<CheckBox
android:id="@+id/aus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:checked="false"
android:text="Australlia"
android:textColor="#154"
android:textSize="20sp"
android:textStyle="bold" /></LinearLayout>
क ४.१३
४.१ .८ ProgressBar
,
. , (spinning wheel
80 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
) (horizontal bar )
(style) .
“ B ” . (indeterminate ) .
(cyclic animation ) .
.
:
1. getMax() – (maximum value)
. (Integer) .
ProgressBar simpleProgressBar=(ProgressBar) findViewById(R.id.simpleProgressBar);
int maxValue=simpleProgressBar.getMax();
2. getProgress() - (progress value) .
(progress value) . .
ProgressBar simpleProgressBar=(ProgressBar)findViewById(R.id.simpleProgressBar);
progressValue=simpleProgressBar.getProgress();
ट ट (Attributes)
1. (id) : id .
2. max: max
. 100, 200 .
3. (progress): 0
. .
Example
<ProgressBar
android:layout_width="match_parent"
android:layout_height="300dp"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:max="100"
android:progress="30" />
81 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ४.१४
(Spinning progressbar )
<ProgressBar
android:layout_width="match_parent"
android:layout_height="300dp"
android:max="100" />
4. indeterminate: indeterminate
indeterminate .
. .
.
<ProgressBar
android:layout_width="match_parent"
android:layout_height="300dp"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:max="100"
82 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:progress="30"
android:indeterminate="true" />
क ४.१५
5. क (background): (background)
. (drawable) .
6. (progressDrawable): (progressDrawable)
.
Step 1: activity_main.xml main.xml .
<ProgressBar
android:id="@+id/simpleProgressBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="60"
android:layout_marginTop="100dp"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:progressDrawable="@drawable/custom_progress"/>
Step 2: drawable folder drawable resource xml
custom_progress .
83 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<item>
<shape>
<gradient
― “
―‗ “
android:useLevel="true" />
</shape>
</item>
</layer-list>
क ४.१६
84 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
४.२
४.२.१ List View:
ListView .
.
.ListView
ListView .
ListView .ListView
, ListView
.
ट ट (Attributes)
1. (id) : id .
2. divider: .
3. ट dividerHeight : . (
), ( ) ( ) .
.
:
Activity_main.xml
<?xml version="1.0"encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@+id/simpleListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="@color/material_blue_grey_800"
85 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:dividerHeight="1dp"/>
</LinearLayout>
MainActivity.java
setContentView(R.layout.activity_main);
ListView l=findViewById(R.id.simpleListView ) ;
l.setAdapter(arr);
}}
क ४. १७
, ListAdapter
. .GridView
86 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
GridView ScrollView
. . GridView
, .
ट ट (Attributes)
1. (id) : id .
2. क numColumns: numColumns .
, “5” auto_fit.
3. horizontalSpacing: horizontalSpacing
. ( ), ( )
( ) .
4. टक verticalSpacing: verticalSpacing
. px, dp sp .
6. strechMode
, .
−
none - .
spacingWidth - .
columnWidth - .
U − ..
:
Activity_main.xml
<GridView
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="3"
android:verticalSpacing="3dp"
87 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:horizontalSpacing="3dp"
android:stretchMode="columnWidth"/>
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView l=findViewById(R.id.grid) ;
ArrayAdapter arr=new ArrayAdapter(this,
android.R.layout.simple_spinner_dropdown_item,fruits);
l.setAdapter(arr);
}}
क ४. १८
88 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
. UI
UI
.
ट ट (Attributes)
1. (id) : id .
2. क (background): (background)
. (drawable) .
3. src: src
.
4. (padding): (padding) (left), (right), (top)
(bottom) .
5. ट paddingRight : .
6. paddingLeft : .
7. ट paddingTop : .
8. ट paddingBottom : .
:
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/android"
android:background="#000"
android:padding="10dp"/>
89 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ४.१८
9. ट (scaleType):
. fit_xy,
center_crop, fitStart .
” ” ” Y”
क ४. १९ क ४.२०
. ScrollView
90 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
(HorizontalScrollView) .
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- ’ -->
</ScrollView>
<HorizontalScrollView
android:id="@+id/horizontalscrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<-- ’ -->
</HorizontalScrollView >
ट ट (Attributes)
1. (id) : id .
2. (scrollbars): , scrollbars
. (vertical), (horizontal)
(none). HorizontalScrollView
.
, .
.
. .
. .
91 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
ट
1. makeText(Context context, CharSequence text, int duration):
. ,
.
(constants):
.
1. LENGTH_LONG: .
.
2. LENGTH_SHORT: .
.
2. show(): . makeText()
.
3. setGravity(int,int,int): .
: , x y .
4. setText(CharSequences): .
makeText()
.
5. setDuration(int duration): .
makeText()
.
6. inflate(int, ViewGroup): xml .
.
7. setView(View): .
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
92 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/showToastButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="showtoast"
android:layout_centerInParent="true"/>
</RelativeLayout>
MainActivity.java
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@Override
public void onClick(View v) {
}});}}
93 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ट (Custom Toast)
, .
Step 2: ( ) ,
Step 3: (setView) .
Step 4: show() .
क ट ट
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/customToast"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_below="@+id/simpleToast"
android:layout_centerHorizontal="true"
android:layout_margin="50dp"
android:background="#0f0"
android:text="Custom Toast"
android:textColor="#fff"
94 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:textSize="20sp" />
</RelativeLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#DAAA"
android:orientation="horizontal"
android:padding="8dp">
<ImageView
android:id="@+id/toastImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:src="@drawable/a3"/>
<TextView
android:id="@+id/toastTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF" />
</LinearLayout>
Mainactivity.java
package com.example.customtoast;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Gravity;
95 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Button;
import android.view.ViewGroup;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
Button customToast;
@Override
setContentView(R.layout.activity_main);
customToast = (Button) findViewById(R.id.customToast);
customToast.setOnClickListener(new View.OnClickListener() {
@Override
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
} }); }}
96 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
४.३.
४.३.१ ट क TimePicker
क ४ .२१
, TimePicker AM/PM 24
. , .
TimePickerDialog .
ट ट (Attributes)
1. (id): id .
2. ट क timePickerMode:
.
ट क
1. setCurrentHour(integer currenthour):
. API 23
. api 23 setHour(Integer hour) .
.
2. setCurrentMinute(integer currentminute):
.
setMinute(Integer minute): setCurrentMinute() API 23 .
api 23 setMinute( ) .
.
3. getCurrentHour():
97 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
. getCurrentHour(): getCurrentHour()
API 23 . api 23 getHour() .
4. getCurrentMinute():
5. setIs24HourView(boolean is24HourView):
24 AM/PM .
(true) (false) . 24
AM/PM
क ४.२२
6. is24HourView():
. 24
AM/PM .
7. setOnTimeChangedListener(TimePicker.OnTimeChangedListener
onTimeChangedListener):
.
onTimeChanged(TimePicker view, int hourOfDay, int minute)
,
.
Activity_main.xml
98 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TimePicker android:id="@+id/simpleTimePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:background="#090"
android:padding="20dp"
android:timePickerMode="spinner" />
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Time Is ::"
android:textColor="#090"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
99 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
MainActivity.java
import android.app.TimePickerDialog;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity {
TextView time;
TimePicker simpleTimePicker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
simpleTimePicker.setIs24HourView(false);
simpleTimePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
} }); }}
100 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
४.३.२ ट क DatePicker
, . UI ,
.
DatePickerDialog .
ट ट (Attributes)
1. (id): id .
2. ट क (datePickerMode): (spinner) (calendar)
क ४ .२३
4. ट paddingRight : .
5. paddingLeft : .
6. ट paddingTop : .
7. ट paddingBottom : .
8. क (background): (background)
. (drawable) .
101 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
ट क
1. setSpinnersShown(boolean shown):
(true) (false) . ,
. .
क ४ .२४
2. getDayOfMonth(): .
.
3. getMonth(): .
.
4. getYear(): .
.
5. getFirstDayOfWeek(): .
.
Activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin"
102 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<DatePicker
android:id="@+id/simpleDatePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#150"
android:datePickerMode="spinner" />
<Button
android:id="@+id/submitButton"
android:layout_width="200dp" android:layout_height="wrap_content"
android:layout_below="@+id/simpleDatePicker" android:layout_centerHorizontal="true"
android:layout_marginTop="50dp" android:background="#150"
android:text="SUBMIT" android:textColor="#fff"
</RelativeLayout>
MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
103 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.view.MenuItem;
import android.view.View;
import android.widget.DatePicker;
import android.widget.Button;
import android.widget.Toast;
DatePicker simpleDatePicker;
Button submit;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
submit.setOnClickListener(new View.OnClickListener() {
@Override
// get the values for day of month , month and year from a date picker
104 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
(Bibliography)
https://abhiandroid.com/ui/datepicker
https://www.javatpoint.com/android-timepicker-example
https://www.javatpoint.com/android-ui-widgets-tutorial
https://www.tutorialspoint.com/android/android_widgets.htm
105 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
गुण (20)
.
.
.
.
५.१.
५.१.१ Intent
.
.
. ट
. ,
startActivity() . Intent
.startActivity()
106 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
. - ( : )
startService() .
startService()
, .( ,
). , ,
. sendBroadcast()
.
1. ट (Explicit Intent)
.
(component) . :
.
.
SecondActivity JAVA .
107 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ५.१
2. ट (Implicit Intent)
, .
. , (App Chooser
) . .
.
Syntax-
ACTION_VIEW .
ACTION_SEND
.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
108 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btn2"
android:text="Implicit Intent" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Activity_second.xml
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
109 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/t1"
android:text="second Activity"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.intentdemo;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button explicit_btn,implicit_btn;
@Override
setContentView(R.layout.activity_main);
explicit_btn = (Button)findViewById(R.id.btn1);
110 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
public void onClick(View v) {
startActivity(intent);
} });
implicit_btn.setOnClickListener(new View.OnClickListener() {
@Override
intent.setData(Uri.parse("https://www.amrutpoly.com"));
startActivity(intent);
} }); }}
AndroidMainfest.xml
<application
android:allowBackup="true" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:theme="@style/Theme.Intentdemo">
<activity android:name=".MainActivity">
<intent-filter>
</intent-filter>
</activity>
<activity android:name=".SecondActivity"></activity>
</application>
</manifest>
secondActivity.java
package com.example.intentdemo;
111 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import android.widget.TextView;
import android.widget.Button;
public class SecondActivity extends AppCompatActivity {
Button b;
@Override
setContentView(R.layout.activity_second);
Toast.makeText(getApplicationContext(), "We are moved to second
Activity",Toast.LENGTH_LONG).show();
}}
५.१.२ Intent-Filter
, (ActivityMainfest.xml)
.
,
. .
, .
ट ट (Attributes)
(icon): . @drawable/image_name.
(label): / .
(priority):
. AndroidManifest.xml .
,
:
112 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<action>
, . ,
<category>
, . , .
<data>
URI ( , , , ) MIME
, .
<activity android:name="ShareActivity"
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter></activity>
.
, .
, . ,
, .
५.२ ट
. .
.
.
. , MainActivity
.
.
(AndroidMainfest.xml)
.
113 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
OS .
क ५.२
ट क (Activity created:onCreate()):
OS onCreate() .
onCreate(Bundle b) .
onCreate(Bundle b) .
, . onCreate(Bundle b)
114 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
. onStart( ) .
onCreate(Bundle b) .
onStart() .
onStart() , onStart()
.onStart() onResume()
onStop() . onStart()
OS . , A
B , A
. A
A .
, .onResume() onStart( )
.
.
onResume()
onResume() .
, OS
onPause() ( )
. .
. .
, 1 2 .
1 .
115 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
.
onRestart() . ,
onRestart() .
onRestart() .
.
.
. ,
.
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("lifecycle","onCreate invoked"); }
@Override
Log.d("lifecycle","onStart invoked"); }
@Override
Log.d("lifecycle","onResume invoked"); }
@Override
116 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
super.onPause();
Log.d("lifecycle","onPause invoked"); }
@Override
Log.d("lifecycle","onStop invoked"); }
@Override
Log.d("lifecycle","onRestart invoked"); }
@Override
Log.d("lifecycle","onDestroy invoked"); }}
क Broadcast Receivers
.
(events . ,
,
. ,
. , .
. ,
(BroadcastReceiver) (BroadcastReceiver)
117 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ५.३
BroadcastReceiver
onReceive() .
AndroidManifest.xml
. ACTION_BOOT_COMPLETED MyReceiver
, .
<application android:icon="@drawable/ic_launcher"android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name="MyReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED">
118 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
</action>
</intent-filter>
</receiver> </application>
System Broadcasts
1. and oid.intent.action.BATTERY_CHANGED
2. and oid.intent.action.BATTERY_LOW
3. and oid.intent.action.BATTERY_OKAY
.
4. and oid.intent.action.BOOT_COMPLETED
5. and oid.intent.action.BUG_REPORT
.
6. android.intent.action.CALL
.Perform a call to someone specified by the data.
7. android.intent.action.CALL_BUTTON
UI " " .
The user pressed the "call" button to go to the dialer or other appropriate UI for placing a call.
8. android.intent.action.DATE_CHANGED
sendBroadcast() .
119 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.broadcast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
setContentView(R.layout.activity_main);
}}
120 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
androidmainifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.broadcast">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Broadcast">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</activity>
<receiver android:name=".AirplaneModeChangeReceiver">
<intent-filter>
<action android:name="android.intent.action.AIRPLANE_MODE_CHANGED">
</action>
</intent-filter>
</receiver> </application></manifest>
AirplaneModeChangeReceiver.java
package com.example.broadcast;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
121 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.os.Build;
import android.provider.Settings;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
public class AirplaneModeChangeReceiver extends BroadcastReceiver {
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
try {
value = Settings.Global.getInt(context.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON);
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
if (value==1) {
Toast.makeText(context, "AirPlane mode is on", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(context, "AirPlane mode is off", Toast.LENGTH_SHORT).show();
} }}
५.३
. ContentResolver
.
, .
.
, , insert(),
122 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
ContentProvider
API .
public class My Application extends ContentProvider { }
क ५.४
५.३.२ Fragments
क ५.५
123 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
.
- . . UI
.
. Fragment
Fragment
Fragment . ,
.
.
.
. API
11 . ,
. xml
. .
124 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
ट क
क ५.६
125 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
5. onViewStateRe to ed Bundle
6. onSta t
7. onRe ume
8. onPau e
9. onStop
11. onDe t oy
12. onDetach
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="com.example.fragment.MainActivity">
<fragment
android:id="@+id/fragment1"
android:name="com.example.fragment.Fragment1"
android:layout_width="0px"
126 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_height="match_parent"
android:layout_weight="1" />
<fragment
android:id="@+id/fragment2"
android:name="com.example.fragment.Fragment2"
android:layout_width="0px"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
Mainactivity.java
package com.example.fragment;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}}
Fragment1.java
package com.example.fragment;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Fragment1 extends Fragment {
127 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
fragment2.java
package com.example.fragment;
import android.os.Bundle;
import android.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
}
@Override
128 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
fragment1_view.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F5F5DC"
tools:context="com.example.fragment.Fragment1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="fragment1" />
</FrameLayout>
Fragment2_view.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F5F5DC"
tools:context="com.example.fragment.Fragment2">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="fragment2" />
</FrameLayout>
129 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
५.४ Service
. ,
, .
UI ( ) .
1. UI
2. .
3. . -
4. stopSelf() stopService()
.
5. .
6. android.app.Service ContextWrapper
. (Manager)
. getSystemService() .
Foreground Service
. ,
.
क Background Service
130 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
.
.
Bound Service
.
. bindService()
. ,
. ,
. ,
, .
1.
<manifest ..>
< ” ”>
...
</application>
</manifest>
2.
3. startService()
4. stopService()
131 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
. :
१) ट (Started service)
( ) startService() ,
. stopService() .
2) (Bound Service)
( . ) bindService() .
unbindService() .
. .
.
. : .
132 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ५ .७
onCreate() .
.
onStartCommand() startService()
. .
onBind() onBind
onUnbind()
onRebind() .. onUnbind
133 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
onDestroy() . . ,
, .
५.४.५ permission
. startService(),bindService(),stopService()
Activity_main.xml
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" tools:context=".MainActivity">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_x="155dp"
android:layout_y="183dp"
android:text="Enable Wifi" />
<Button android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="155dp"
android:layout_y="246dp"
android:text="Disable Wifi" />
134 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
</AbsoluteLayout>
Mainactivity.java
package com.example.wifiservice;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Bundle; import
android.view.View; import
android.widget.Button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
enableButton=(Button)findViewById(R.id.button1);
disableButton=(Button)findViewById(R.id.button2);
WifiManager wifi = (WifiManager)
getApplicationContext().getSystemService(Context.WIFI_SERVICE);
enableButton.setOnClickListener(new View.OnClickListener(){
} });
disableButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
wifi.setWifiEnabled(false); }
});
}}
135 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.wifiservice">
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Wifiservice">
<activity android:name=".MainActivity">
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent"
136 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
tools:context=".MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start Service"
android:id="@+id/startservice"/>
<Button
android:id="@+id/stopservice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="95dp"
android:text="Stop Service" />
</AbsoluteLayout>
MainActivity.java
package com.example.services;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Service;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
137 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
});
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}); }}
MyService.java
package com.example.services;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
}
public void onCreate() {
138 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
public void onStart(Intent intent, int startId) {
}
@Override
}
}
AndroidMainfest.xml
package="com.example.services">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Services">
<activity android:name=".MainActivity">
<intent-filter>
</intent-filter>
</activity>
139 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
</manifest>
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Start Service"
android:id="@+id/startservice"/>
<Button
android:id="@+id/stopservice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="95dp"
MainActivity.java
package com.example.music_service;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
140 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
setContentView(R.layout.activity_main);
}
}
MyService.java
package com.example.music_service;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.provider.Settings;
import android.widget.Toast;
public class MyService extends Service {
return null;
}
141 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
player.setLooping(true);
player.start();
}
@Override
player.stop();
Toast.makeText(this, "Service Stopped", Toast.LENGTH_LONG).show();
}}
AndroidMainfest.xml
package="com.example.music_service">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Music_service">
<activity android:name=".MainActivity">
<intent-filter>
142 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
</intent-filter>
</activity>
<service android:name=".MyService" />
</application>
</manifest>
५.५
, , ,
/ h/w .
.
क ५ .८
143 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Android / .
MediaPlayer .MediaPlayer .
MediaPlayer / . . MediaPlayer (pause) ,
. MediaPlayer (ms ),
.MediaPlayer (ms )
, , .
MediaPlayer , create() . MediaPlayer
. –
mediaPlayer.start();
mediaPlayer.pause();
start() , . pause ()
, .
mediaPlayer.reset()
, reset() . .
. MediaPlayer
.
MediaPlayer
1. isPlaying()
2. seekTo(position)
3. getCurrentPosition()
144 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
4. getDuration()
5. reset()
6. release()
8. setDataSource(FileDescriptor fd)
9. selectTrack(int index)
10. getTrackInfo()
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:ignore="HardcodedText">
<TextView
android:id="@+id/headingText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
145 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:text="MEDIA PLAYER"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/headingText"
android:layout_marginTop="16dp"
android:gravity="center_horizontal">
<Button
android:id="@+id/stopButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="STOP" />
<Button
android:id="@+id/playButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PLAY" />
<Button
android:id="@+id/pauseButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PAUSE" />
</LinearLayout>
</RelativeLayout>
package com.example.mediaplayer;
import android.media.MediaPlayer;
146 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.os.Bundle;
import android.provider.Settings;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button bPlay,bPause,bStop;
MediaPlayer mediaPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bPause= findViewById(R.id.pauseButton);
bStop = findViewById(R.id.stopButton);
bPlay.setOnClickListener(new View.OnClickListener() {
@Override
Toast.makeText(getApplicationContext(),"PLaying song",Toast.LENGTH_SHORT).show();
} });
bPause.setOnClickListener(new View.OnClickListener() {
@Override
Toast.makeText(getApplicationContext(),"song paused",Toast.LENGTH_SHORT).show();
} });
147 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
bStop.setOnClickListener(new View.OnClickListener() {
@Override
mediaPlayer.stop();
Toast.makeText(getApplicationContext(),"song stopped",Toast.LENGTH_SHORT).show();
} }); }}
.
. TextToSpeech
. , initListener
.initListener TextToSpeech ,
, . TextToSpeech
{
//specify properties of TextToSpeech
} });
setLanguage() . setLanguage
. U Y Y .
, TextToSpeech speak() .
TextToSpeech
2. getLanguage
3. i Speaking
148 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
4. setPitch(float pitch)
TextToSpeech .
5. setSpeechRate(float speechRate)
.
6. shutdown()
TextToSpeech .
7. stop()
.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:transitionGroup="true">
<TextView android:text="Text to Speech" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textview"
android:textSize="35dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_below="@+id/textview"
android:layout_marginTop="46dp"
android:hint="Enter Text"
149 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#ff7aff10"
android:textColorHint="#ffff23d1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text to Speech"
android:id="@+id/button"
android:layout_below="@+id/editText"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp" />
</RelativeLayout>
MainActivity.java
package com.example.texttospeech;
import android.app.Activity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.util.Locale;
import android.widget.Toast;
EditText ed1;
Button b1;
150 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ed1=(EditText)findViewById(R.id.editText);
b1=(Button)findViewById(R.id.button);
t1=new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR) {
t1.setLanguage(Locale.UK);
}
} });
b1.setOnClickListener(new View.OnClickListener() {
@Override
Toast.makeText(getApplicationContext(), toSpeak,Toast.LENGTH_SHORT).show();
t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);
}
}); }
t1.stop();
t1.shutdown();
}
super.onPause();
}}
151 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
५.५.५ Sensor
. - (motion),
(Motion Sensors)
. (accelerometers ),
(gravity sensors), (gyroscopes) (rotational vector
sensors) .
(Environmental sensors)
, (temperature)
(Position sensors)
. (orientation sensors )
ग्न (magnetometers) .
API
(SensorManager) :
.
(Sensor) : , , .
ट (SensorEvent) : .
152 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
ट (SensorEventListener) ट :
. , SensorManager
. .
SensorManager sMgr;
sMgr = (SensorManager)this.getSystemService(SENSOR_SERVICE);
SensorManager getDefaultSensor()
.
Sensor light;
light = sMgr.getDefaultSensor(Sensor.TYPE_LIGHT);
, onAccuracyChanged and
onSensorChanged .
sMgr.registerListener(this, light,SensorManager.SENSOR_DELAY_NORMAL);
getSensorList
. .
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
153 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:transitionGroup="true">
<TextView android:text="Sensor " android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textview"
android:textSize="35dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:id="@+id/textView2"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
package com.example.sensor;
import android.app.Activity;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import java.util.List;
154 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.hardware.Sensor;
import android.hardware.SensorManager;
TextView tv1;
private SensorManager mSensorManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
} }}
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
155 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:id="@+id/textview2"/>
</androidx.constraintlayout.widget.ConstraintLayout>
package com.example.sensorxyz;
import androidx.appcompat.app.AppCompatActivity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;
import java.util.List;
SensorManager mSensorManager;
@Override
setContentView(R.layout.activity_main);
tv1 = (TextView) findViewById(R.id.textview2);
mSensorManager.registerListener(this,mList.get(0),SensorManager.SENSOR_DELAY_NORMAL); }
@Override
156 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
tv1.setText("x="+value[0]+"y="+value[1]+"z="+value[2]);
}
@Override
package com.example.sensor;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Color;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Toast;
RelativeLayout c;
@Override
157 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
setContentView(R.layout.activity_main);
//view.setBackgroundColor(Color.GREEN);
lastUpdate = System.currentTimeMillis();
c=findViewById(R.id.main);
}
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
@Override
float x = values[0];
float y = values[1];
float z = values[2];
float accelationSquareRoot = (x * x + y * y + z * z) / (SensorManager.GRAVITY_EARTH *
SensorManager.GRAVITY_EARTH);
long actualTime = System.currentTimeMillis();
c.setBackgroundColor(Color.GREEN);
} else {
c.setBackgroundColor(Color.RED);
Toast.makeText(this, "shuffled", Toast.LENGTH_SHORT).show();
158 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
}
isColor = !isColor;
} } }
// register this class as a listener for the orientation and accelerometer sensors
sensorManager.registerListener((SensorEventListener)
this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
SensorManager.SENSOR_DELAY_NORMAL);
}
protected void onPause() {
// unregister listener
super.onPause(); sensorManager.unregisterListener((SensorEventListener) this); }}
AsyncTask
. .asynctask
.AsyncTasks
( ).
क ५ .९
159 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
,
. /
. AsyncTasks
.AsyncTask doInBackground()
GUI . onPostExecute()
UI .doInBackground
.
AsyncTask
onPreExecute() -
.
doInBackground() ,
asyncTask .
doInBackground(Params) – .
.
onP og e Update p og e … − , UI
, .
onPostExecute(Result) – ui .
Async ट क क
TypeOfVarArgParams – .
ProgressValue – .
onProgressUpdate() UI .
ResultValue – .
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
160 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<TextView
android:id="@+id/tv_time"
android:layout_width="wrap_content"
andr ”
android:textSize="10pt"
android:textColor="#444444"
android:layout_alignParentLeft="true"
android:layout_marginRight="9dip"
android:layout_marginTop="20dip"
android:layout_marginLeft="10dip"
android:text="Sleep time in Seconds:"/>
<EditText
android:id="@+id/in_time"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:background="@android:drawable/editbox_background"
android:layout_toRightOf="@id/tv_time"
android:layout_alignTop="@id/tv_time"
android:inputType="number"/>
<Button
android:id="@+id/btn_run"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
161 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_centerHorizontal="true"
android:layout_marginTop="64dp" />
<TextView
android:id="@+id/tv_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="7pt"
android:layout_below="@+id/btn_run"
android:layout_centerHorizontal="true" />
</RelativeLayout>
MainActivity.java
package com.example.asynctaskdemo;
import androidx.appcompat.app.AppCompatActivity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
162 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
setContentView(R.layout.activity_main);
time = (EditText) findViewById(R.id.in_time);
@Override
public void onClick(View v) {
runner.execute(sleepTime); } });
private class AsyncTaskRunner extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
publishProgress("Sleeping...");
try {
e.printStackTrace();
resp = e.getMessage();
} catch (Exception e) {
e.printStackTrace();
resp = e.getMessage();
}
return resp;
}
163 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
protected void onPostExecute(String result) {
progressDialog.dismiss();
finalResult.setText(result);
}
@Override
protected void onPreExecute() {
}
@Override
}}}
५.६.१ क Audio capture
. MediaRecorder
. MediaRecorder .MediaRecorder
, MediaRecorder . .
MediaRecorder myAudio = new MediaRecorder();
myAudio.setAudioSource(MediaRecorder.AudioSource.MIC);
myAudio.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
myAudio.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
myAudio.setOutputFile(outputFile);
,
(prepare) .
164 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
myAudioRecorder.prepare();
myAudioRecorder.start();
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools=http://schemas.android.com/tools
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<TextView
android:id="@+id/txthead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="media recorder"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="30sp"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/idTVstatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="150dp"
android:text="status"
165 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:textAlignment="center"
android:textSize="18sp"
android:gravity="center_horizontal" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="4">
<TextView
android:id="@+id/btnRecord"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@color/purple_500"
android:padding="5dp"
android:text="start_recording"
android:textAlignment="center"
android:textColor="@color/white"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/btnStop"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@color/purple_500"
166 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:padding="5dp"
android:text="stop_recording"
android:textAlignment="center"
android:textColor="@color/white"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/btnPlay"
android:layout_width="0dp
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@color/purple_500"
android:padding="5dp"
android:text="play_recording"
android:textAlignment="center"
android:textColor="@color/white"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/btnStopPlay"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="@color/purple_500"
android:lines="2"
android:padding="5dp"
android:text="stop_playing"
android:textAlignment="center"
android:textColor="@color/white"
167 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:gravity="center_horizontal" />
</LinearLayout></RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=http://schemas.android.com/apk/res/android
package="com.example.audio_capture">
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Audio_capture">
<activity android:name=".MainActivity">
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
package com.example.audio_capture;
import android.content.pm.PackageManager;
168 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import java.io.IOException;
import static android.Manifest.permission.RECORD_AUDIO;
setContentView(R.layout.activity_main);
statusTV = findViewById(R.id.idTVstatus);
startTV = findViewById(R.id.btnRecord);
stopTV = findViewById(R.id.btnStop);
playTV = findViewById(R.id.btnPlay);
stopplayTV = findViewById(R.id.btnStopPlay);
169 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
stopTV.setBackgroundColor(getResources().getColor(R.color.gray));
playTV.setBackgroundColor(getResources().getColor(R.color.gray));
stopplayTV.setBackgroundColor(getResources().getColor(R.color.gray));
startTV.setOnClickListener(new View.OnClickListener() {
@Override
} });
stopTV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pauseRecording();} });
playTV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playAudio();
} });
stopplayTV.setOnClickListener(new View.OnClickListener() {
@Override
stopTV.setBackgroundColor(getResources().getColor(R.color.purple_200));
startTV.setBackgroundColor(getResources().getColor(R.color.black));
playTV.setBackgroundColor(getResources().getColor(R.color.gray));
stopplayTV.setBackgroundColor(getResources().getColor(R.color.gray));
mFileName = Environment.getExternalStorageDirectory().getAbsolutePath();
mFileName += "/AudioRecording.3gp";
170 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile(mFileName);
try {
mRecorder.prepare(); }
catch (IOException e) {
Log.e("TAG", "prepare() failed"); }
mRecorder.start();
statusTV.setText("Recording Started");
} else {
RequestPermissions(); } }
startTV.setBackgroundColor(getResources().getColor(R.color.purple_200));
playTV.setBackgroundColor(getResources().getColor(R.color.black));
stopplayTV.setBackgroundColor(getResources().getColor(R.color.purple_200));
mPlayer = new MediaPlayer();
try {
mPlayer.setDataSource(mFileName);
mPlayer.prepare();
mPlayer.start();
171 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
stopTV.setBackgroundColor(getResources().getColor(R.color.black));
startTV.setBackgroundColor(getResources().getColor(R.color.purple_200));
playTV.setBackgroundColor(getResources().getColor(R.color.purple_200));
stopplayTV.setBackgroundColor(getResources().getColor(R.color.purple_200));
mRecorder.stop();
mRecorder.release();
mRecorder = null;
statusTV.setText("Recording Stopped"); }
public void pausePlaying() {
mPlayer.release();
mPlayer = null;
stopTV.setBackgroundColor(getResources().getColor(R.color.gray));
startTV.setBackgroundColor(getResources().getColor(R.color.purple_200));
playTV.setBackgroundColor(getResources().getColor(R.color.purple_200));
stopplayTV.setBackgroundColor(getResources().getColor(R.color.gray));
५.६.२ क camera
.
. :
क टट(Camera Intent)
.
MediaStore.ACTION_IMAGE_CAPTURE ACTION_VIDEO_CAPTURE
. MediaStore
172 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
. API :
1.CameraManager:
.
2.CameraDevice: .
3.CaptureRequest: .
4.CameraCaptureSession: CameraCaptureSession
.
5.CameraCaptureSession.CaptureCallback: .
क टक
क (Camera Permission) -
.
<uses-permission android:name="android.permission.CAMERA"/>
क (Camera Features) -
, :
<uses-feature android:name="android.hardware.camera" />
.
<uses- “>
173 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools=http://schemas.android.com/tools
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="24sp"
android:layout_marginTop="25sp"/>
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:layout_below="@id/button" />
</RelativeLayout>
MainActivity.java
package com.example.image_capture;
import android.content.Intent;
174 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
Button btnTakePhoto;
ImageView imageView;
setContentView(R.layout.activity_main);
btnTakePhoto = findViewById(R.id.button);
imageView = findViewById(R.id.imageView);
btnTakePhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
} }); }
@Override
imageView.setImageBitmap(bitmap); } }}
175 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=http://schemas.android.com/apk/res/android
package="com.example.image_capture">
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Image_Capture">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</activity>
</application>
</manifest>
५.७
५.७.१ ट Bluetooth
. API .
176 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
BluetoothAdapter . getDefaultAdapter()
. .
, ACTION_REQUEST_ENABLE
.
.
Intent turnOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnOn, 0);
API :
ACTION_REQUEST_DISCOVERABLE
ACTION_STATE_CHANGED
ACTION_FOUND
, getBondedDevices()
. . .
private Set<BluetoothDevice>pairedDevices;
pairedDevices = BA.getBondedDevices();
Activity_main.xml
177 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools=http://schemas.android.com/tools
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:layout_margin="14dp"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bluetooth"
android:textSize="20dp"
android:textStyle="bold"/>
<Button
android:id="@+id/on"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn On" />
<Button
android:id="@+id/getvisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listdevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List Devices" />
178 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<Button
android:id="@+id/off"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Turn OFF" />
<ListView
android:id="@+id/lv"
android:layout_width="279dp"
android:layout_height="284dp"/>
</LinearLayout>
MainActivity.java
package com.example.bluetoothpr24;
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_ENABLE;
import androidx.appcompat.app.AppCompatActivity;
import java.util.ArrayList;
import java.util.Set;
public class MainActivity extends AppCompatActivity {
Button on,off,getvisible,listdevice;
final BluetoothAdapter bAdapter = BluetoothAdapter.getDefaultAdapter();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
on = (Button) findViewById(R.id.on);
off = (Button) findViewById(R.id.off);
179 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
lv = (ListView) findViewById(R.id.lv);
on.setOnClickListener(new View.OnClickListener() {
@Override
off.setOnClickListener(new View.OnClickListener() {
@Override
}});
getvisible.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listdevice.setOnClickListener(new View.OnClickListener() {
@Override
lv.setAdapter(adapter); }
}); }}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=http://schemas.android.com/apk/res/android
package="com.example.bluetoothpr24">
180 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.BluetoothPr24">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
181 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ५.१०
५.७.२ Animation
. .
.
(View Animation):
.
. . , ,
, , ,
, ,
. , ,
.
ट (Property Animation):
.
(Drawable Animation):
182 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
, Animation .
, AnimationUtils loadAnimation
.
−
Activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools=http://schemas.android.com/tools
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:paddingTop="12dp"
android:paddingBottom="12dp" tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alert Dialog"
android:id="@+id/textView"
android:textSize="35dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
183 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Amrutvahini"
android:id="@+id/textView2"
android:textColor="#ff3eff0f"
android:textSize="35dp"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/download"
android:layout_below="@+id/textView2"
android:layout_alignRight="@+id/textView2"
android:layout_alignEnd="@+id/textView2"
android:layout_alignLeft="@+id/textView"
android:layout_alignStart="@+id/textView"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="zoom"
android:id="@+id/button"
android:layout_below="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="40dp"
android:onClick="clockwise"/>
184 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="clockwise"
android:id="@+id/button2"
android:layout_alignTop="@+id/button"
android:layout_centerHorizontal="true"
android:onClick="zoom"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fade"
android:id="@+id/button3"
android:layout_alignTop="@+id/button2"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:onClick="fade"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="blink"
android:onClick="blink"
android:id="@+id/button4"
android:layout_below="@+id/button"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
185 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:text="move"
android:onClick="move"
android:id="@+id/button5"
android:layout_below="@+id/button2"
android:layout_alignRight="@+id/button2"
android:layout_alignEnd="@+id/button2"
android:layout_alignLeft="@+id/button2"
android:layout_alignStart="@+id/button2" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="slide"
android:onClick="slide"
android:id="@+id/button6"
android:layout_below="@+id/button3"
android:layout_toRightOf="@+id/textView"
android:layout_toEndOf="@+id/textView" />
</RelativeLayout>
MainActivity.java
package com.example.animation;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends Activity {
186 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
ImageView image;
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image= (ImageView)findViewById(R.id.imageView);
}
R.anim.myanimation);
image.startAnimation(animation);
}
public void zoom(View view){
image.startAnimation(animation1);
}
R.anim.fade_animation);
image.startAnimation(animation1);
}
public void blink(View view){
image.startAnimation(animation1);
}
187 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
image.startAnimation(animation1);
}
}}
blink_animation.xml
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="500"
android:repeatMode="reverse"
android:repeatCount="infinite"/>
</set>
Clockwise.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000" >
</rotate>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:startOffset="5000"
android:fromDegrees="360"
188 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:toDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="5000" >
</rotate>
</set>
Fade_animation.xml
android:interpolator="@android:anim/accelerate_interpolator">
<!-- duration is the time for which animation will work-->
<alpha
android:duration="1000"
android:fromAlpha="0"
android:toAlpha="1" />
<alpha
android:duration="1000"
android:fromAlpha="1"
android:startOffset="2000"
android:toAlpha="0" />
</set>
Move.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="0%p"
android:toXDelta="75%p"
189 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:duration="700" />
</set>
Myanimation.xml
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0.5"
android:toXScale="3.0"
android:fromYScale="0.5"
android:toYScale="3.0"
android:duration="5000"
android:pivotX="50%"
android:pivotY="50%" >
</scale>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:startOffset="5000"
android:fromXScale="3.0"
android:toXScale="0.5"
android:fromYScale="3.0"
android:toYScale="0.5"
android:duration="5000"
android:pivotX="50%"
android:pivotY="50%" >
</scale>
</set>
Slide.xml
<?xml version="1.0" encoding="utf-8"?>
190 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="0.0" />
</set>
Zoom.xml
<?xml version="1.0" encoding="utf-8"?>
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="0.0" />
</set>
५.८
SQLite SQL .
SQLite .
.
, .
191 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
.android.database.sqlite.SQLiteOpenHelper
. , SQLiteOpenHelper onCreate()
onUpgrade() .
SQLiteOpenHelper क
SQLiteOpenHelper .
, .
, . .
SQLiteOpenHelper
public ab t act void onC eate SQLiteDataba e db
public ab t act void onUpg ade SQLiteDataba e db, int oldVe ion, int newVe ion
SQLiteDatabase class
, , , .
SQLiteDatabase
void execSQL(String sql)
sql .
int update(String table, ContentValues values, String whereClause, String[] whereArgs)
192 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
.
long insert(String table, String nullColumnHack, ContentValues values)
. table ,nullColumnHack
. , , .
.
Cursor query(String table, String[] columns, String selection, String[] selectionArgs, String
groupBy, String having, String orderBy)
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools=http://schemas.android.com/tools
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="submit"
193 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
app:layout_constraintBottom_toTopOf="@+id/button3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText2" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="show"
app:layout_constraintBottom_toTopOf="@+id/textView1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editText2"
app:layout_constraintVertical_bias="0.778" />
<TextView
android:id="@+id/textView1"
android:layout_width="259dp"
android:layout_height="212dp"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.585"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.911" />
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
194 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
package com.example.sqlite_insert;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.text.Editable;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
SQLiteDatabase Student_database;
@Override
setContentView(R.layout.activity_main);
final EditText eroll = (EditText)findViewById(R.id.editText2);
195 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
bsubmit.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
//openOrCreateDatabase("student",null);
Student_database.execSQL("CREATE TABLE IF NOT EXISTS stud(name VARCHAR(20));");
String s, s1;
s1 = eroll.getText().toString();
stored",Toast.LENGTH_LONG).show();
Student_database.close();
}
});
bshow_details.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
int total = 0, n;
Cursor C3=Student_database.rawQuery("select * from stud;",null);
C3.moveToFirst();
if(!C3.isAfterLast())
{
do{
s6 = C3.getString(0);
tvstuddetails.append("\n" + s6);
}while(C3.moveToNext());
}
Student_database.close();
}
196 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
});
}}
Example 2
package com.example.sq;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import org.w3c.dom.Text;
public class MainActivity extends AppCompatActivity {
Button b1,b2,b3;
TextView t;
SQLiteDatabase db;
String d1,d2,d3,d4,d5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=findViewById(R.id.b1);
b2=findViewById(R.id.b2);
b3=findViewById(R.id.b3);
t=findViewById(R.id.t);
197 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
}
public void insert(View v){
}
public void view(View v){
String s6;
int total = 0, n;
if(!C3.isAfterLast())
{
do{
s6 = C3.getString(0)+C3.getInt(1)+C3.getInt(2)+C3.getString(3)+C3.getInt(4);
t.append("\n" + s6);
}while(C3.moveToNext());
} }
public void delete(View v){
}}
198 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools=http://schemas.android.com/tools
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="insert"
android:onClick="insert"
android:id="@+id/b1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="view"
android:onClick="view"
android:id="@+id/b2"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="delete"
199 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:onClick="delete"
android:id="@+id/b3"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/t"/>
</LinearLayout></androidx.constraintlayout.widget.ConstraintLayout>
. .
- , -1.
- .
200 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
int .
201 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
, .
.
24. abstract boolean moveToPosition(int position)
५.८.५ ट Transactions
void beginTransaction():transaction
void setTransactionSuccessful():the transaction .
SQLiteDatabase.beginTransaction() . ,
202 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
, , SQLiteDatabase.endTransaction()
SQLiteDatabase.setTransactionSuccessful() . endTransaction()
setTransactionSuccessful() , ,
. setTransactionSuccessful() endTransaction()
, setTransactionSuccessful() endTransaction() -
. ,
setTransactionSuccessful() endTransaction()
(Bibliography)
https://www.geeksforgeeks.org/multimedia-framework-in-android/
https://developer.android.com/media/platform/mediaplayer
https://www.javatpoint.com/playing-audio-in-android-example
https://www.javatpoint.com/android-sqlite-tutorial
https://www.geeksforgeeks.org/how-to-create-and-add-data-to-sqlite-database-in-android/
https://www.tutlane.com/tutorial/android/android-texttospeech-with-examples
203 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
एिएमएि िोटोकॉल वापरून SMS पाठवणे आसण िाप्त करणे िंबंसधत आहे .
एक एं डरॉइड अॅप्लिकेशनमध्ये SMS टे लीफोनी वापरण्यािाठी, तुम्हाला टे लीफोनी िेवेची अनुमती समोवणे आवडे ल.
SmsManager smsManager =
SmsManager.getDefault();smsManager.sendTextMessage(phoneNumber, null, message, null, null);
SmsManager API
SmsManager smsManager = SmsManager.getDefault();
204 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
startActivity(sendIntent);
Of course, both need SEND_SMS permission.
class.
ही पद्धत िंदेशाच्या मजकुराचे अनेक तुकड्यां मध्ये सवभाजन करते , कमाल SMS िंदेश आकारापेक्षा मोठा नाही.
२.static SmsManager getDefault()
एक बॅकग्रौंड िप्लव्हिि अिते ज्याने नवीन एिएमएि िाप्त केल्यावर तुमच्या अनुियोगाला िूचना दे ते.
उद हरण-
205 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
setContentView(R.layout.activity_phone_info);
// Get references to TextViews in the layout
getSystemService(TELEPHONY_SERVICE);
if (telephonyManager != null) {
206 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
} else {
imeiTextView.setText("IMEI: Not available");
}
}
SmsManager
.
१. Android Studio IDE .
२. src/MainActivity.java
.
.
४. res/values/strings.xml .
.
५. AndroidManifest.xml
६.
.
package com.example.;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.telephony.SmsManager;
import android.util.Log;
import android.view.Menu;
207 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
EditText txtphoneNo;
EditText txtMessage;
String phoneNo;
String message;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
});
}
protected void sendSMSMessage() {
phoneNo = txtphoneNo.getText().toString();
message = txtMessage.getText().toString();
if (ContextCompat.checkSelfPermission(this,Manifest.permission.SEND_SMS)!=
PackageManager.PERMISSION_GRANTED) {
208 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.SEND_SMS)) {
} else {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.SEND_SMS},
MY_PERMISSIONS_REQUEST_SEND_SMS);
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode,String permissions[], int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_SEND_SMS: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
Toast.makeText(getApplicationContext(),
} }
}
}
}
209 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools=http://schemas.android.com/tools
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="MainActivity">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textSize="30dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30dp"
android:layout_below="@+id/textView1"
android:layout_alignRight="@+id/imageButton"
android:layout_alignEnd="@+id/imageButton" />
<ImageButton
android:layout_width="wrap_content"
210 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@drawable/abc"
android:layout_below="@+id/textView2"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:textColorHint="@color/abc_primary_text_material_dark"
android:layout_below="@+id/imageButton"
android:layout_centerHorizontal="true" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText2"
android:layout_below="@+id/editText"
android:layout_alignLeft="@+id/editText"
android:layout_alignStart="@+id/editText"
android:textColorHint="@color/abc_primary_text_material_dark"
android:layout_alignRight="@+id/imageButton"
android:layout_alignEnd="@+id/imageButton"
android:hint="Enter SMS" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Sms"
211 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:id="@+id/btnSendSMS"
android:layout_below="@+id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginTop="48dp" />
</RelativeLayout>
Following will be the content of e /value / t ing .xml to define two new con tant −
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">tutorialspoint</string>
</resources>
Following i the default content of And oidManife t.xml −
package="com.example.tutorialspoint" >
<uses-permission android:name="android.permission.SEND_SMS" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.tutorialspoint.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</activity>
</application>
212 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
</manifest>
Output:
क ६ .१
. ,
API .
?
, , , .
क API क (Key)
213 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
२. क :
, "Select a Project" "New Project"
३. API क :
, "APIs & Services" > "Dashboard" .
५.API Key :
, google_maps_api.xml .
API key :
<resources>
</resources>
YOUR_API_KEY_HERE API XML .
६.३ Google क
. Google ,
, . Google .
१.Google क क
Google , .
. .
214 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
: ,
: .
.
: , .
: . ,
.
क : .
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
Google नकाशा API अनेक पद्धती िदान करते ज्या Google नकाशा िानुकूसलत करण्यात मदत करतात. या पद्धती
खालीलिमाणे आहे त.
1.getMapAsync() मेथड:
त्या कोड रृंगार करण्यािाठी वापरला जातो ज्यानुिार गुगल मॅपमध्ये ऑब्जेक्ट तयार करतो आसण त्याचं वापर
करतो. त्याचं एक िमुख उदाहरण खालीलिमाणे सदलं जातं.
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
});
215 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
googleMap.moveCamera(CameraUpdateFactory.newLatLng(location));
3. म कशर जोडणे:
googleMap.addMarker(new MarkerOptions()
.title("माकिरचं शीषिक")
मानचं स्थान समोवण्यािाठी getMyLocation() मेथड वापरा. स्थान अपडे ट करण्यािाठी setMyLocationEnabled()
मेथड वापरा.
6. म गश दशशविणे:
मागि दशिसवण्यािाठी Intent वापरा सकंवा Google Maps API वापरता तर त्यािाठी Direction API वापरा.
startActivity(intent);
. Google Maps :
१. Google Cloud Platform क :
"Select a project" - .
216 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
"New Project" .
"Create" .
.
"Enable APIs and Services" .
"Credentials" .
"Create Credentials" "API Key" .
API .
५. Android Studio क क :
"google_maps_api.xml" API .
google_maps_api.xml <string name="google_maps_key"
templateMergeStrategy="preserve" translatable="false">YOUR_API_KEY</string>
YOUR_API_KEY API .
७. ट :
"MapsActivity.java" .
import androidx.fragment.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
217 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in a location of your choice
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}}
८. ट :
"res/layout/activity_maps.xml" XML .
xmlns:tools=http://schemas.android.com/tools
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity">
<fragment
android:id="@+id/map"
218 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
९. अॅप्लिकेशन रन कर :
• आपले अॅप्लिकेशन तयार केलं जाईल आसण आपले सडव्हाइि सकंवा एम्युलेटरवर रन करा.
क ६ .२
६.४ कट
,
. ( )
. API 29 .
क ६ .३
219 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
मध्ये Zoom Control अांमलबज िणीस ठी तुमचां ऍप Google Map ि परत असल्य स, ख लील मेथड् स
तुम्ह ल तुमच्य ऍपमध्ये Zoom Control जोडण्य त मदत करू शकत त:
CameraUpdateFactory.zoomOut() मेथड् ि वापरा. इ.ि. तुम्ही सजथे सतथे तुम्ही तुमचं मैप Zoom In आसण Zoom
Out करू शकता.
या मेथडिाठी एक LatLng आसण एक float (Zoom Level) अिायचं. त्यानुिार, तुम्ही वापरकत्याि चं स्थान आसण त्यां चं
Zoom Level सदलेलं मैपवर Zoom करू शकता.
3. setOnCameraIdleListener() मेथड:
तुम्ही setOnCameraIdleListener() मेथड वापरून मैपवर Camera बदलतानाचं इवेंट िुसनसित करू शकता. तेव्हा
तुम्ही जेव्हा तु म्हाला मानचं आहे की Zoom नीटाचं बदललंय, तेव्हा तुम्ही कोड सलहू शकता.
तुम्हाला जेव्हा तुम्हाला Zoom Control बटणंिह मैपवर Zoom करायचं तेव्हा तु म्ही
setOnCameraMoveStartedListener() आसण setOnCameraMoveListener() मेथडि वापरून कोड सलहू
या मेथड् िचं वापर करून तुम्ही तुमच्या ऍपमध्ये Zoom Control अंमलबजावणी करू शकता.
Example कट
ऍपमध्ये Zoom Control अांमलबज िणीस ठी ख लील पदक्रम ांवकांचे सुचन आहे:
1.Zoom Control जोड :
तुमच्या ऍपमध्ये Zoom Control जोडण्यािाठी, XML लेआउट फाइलमध्ये ZoomControls वापरा.
<ZoomControls
220 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:id="@+id/zoomControls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center" />
2. Zoom Control इवनवशयल ईज कर :
तुम्ही Google Maps वापरता आहात तर, तुम्हाला Google Map तयार करावंता हवंचं आहे .
GoogleMap googleMap = ... // GoogleMap तयार करा
zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
@Override
googleMap.animateCamera(CameraUpdateFactory.zoomOut());
}
221 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
});
त्यािाठी तुम्ही CameraUpdateFactory.zoomIn() आसण CameraUpdateFactory.zoomOut() मेथड् िचं वापरून
जेव्हा तुम्ही तुमचं ऍप चालवलंय, तेव्हा तुम्ही Zoom Control वापरून स्थानां तर अथवा कोणत्याही इतर
उपयोगां िाठी स्थान िंपासदत करू शकता.
XML Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="@+id/image_View"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/indiamap" />
<ZoomControls
android:id="@+id/zoom_controls"
222 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_margin="10dp" />
</RelativeLayout>
Java Code:
// Java code to implement the zoom controls
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.ZoomControls;
public class MainActivity extends AppCompatActivity {
ImageView imageView;
ZoomControls zoomControls;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView=findViewById(R.id.image_View);
zoomControls=findViewById(R.id.zoom_controls);
zoomControls.setBackgroundColor(Color.BLACK);
zoomControls.show();
// onTouch listener function when the image is clicked
223 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
imageView.setOnTouchListener(
new View.OnTouchListener() {
@Override
return false;
}
}
);
zoomControls.setOnZoomInClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
float x=imageView.getScaleX();
float y=imageView.getScaleY();
imageView.setScaleX((float)(x+0.5f));
imageView.setScaleY((float)(y+0.5f));
zoomControls.hide();
}
}
);
zoomControls.setOnZoomOutClickListener(
new View.OnClickListener() {
224 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
public void onClick(View view) {
float x=imageView.getScaleX();
float y=imageView.getScaleY();
if(x==1 && y==1)
{
// the scale will remain same,since
imageView.setScaleY((float)(y));
zoomControls.hide();
}
else
{
// setting the new scale
imageView.setScaleX((float)(x-0.5f));
imageView.setScaleY((float)(y-0.5f));
}
}
}
);
}
}
Output:
225 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क ६.४
import androidx.fragment.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
226 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
@Override
public boolean onMarkerClick(Marker marker) {
}
});
227 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
}}
.
3. mMap.moveCamera(CameraUpdateFactory.newLatLng(markerLocation)); -
.
4. mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {...}); -
.
Google Map वर Marker जोडण्याची िसहृया ऍपमध्ये िवाा िाठी एक अत्यंत महत्त्वाची सहृया आहे . खालील
िदसशित उदाहरणात, तुम्ही एक Google Map वर Marker जोडून त्यां चं स्थान दशिवू सशकून जुनी Marker िोडू आसण
नवीन Marker जोडूची िसहृया िां सगतली आहे :
Cloud Console वर जाऊन एक नवीन API की बनवा आसण त्याची कीवडि समोवा.
2.Google Maps Dependency जोड :
तुमच्या build.gradle फाइलमध्ये Google Maps dependency जोडून तुम्हाला तुमच्या ऍपमध्ये Google Maps वापरू
शकेल.
implementation 'com.google.android.gms:play-services-maps:17.0.1'
3.XML लेआउटमध्ये MapView जोड :
तुमच्या XML लेआउटमध्ये MapView जोडून तुम्ही Google Map दशिवू शकता.
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
228 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
android:layout_height="match_parent"
android:apiKey="तुमचं API कीवडि "
तुमच्या Java फाइलमध्ये , MapView इसनसशयलाईज करा आसण आपले Google Map वकि करून तयार करा.
MapView mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
});
5. मैपिर Marker जोड आवण क ही सुचन दशशि :
तुम्ही तुमच्या कोडमध्ये आपलं Marker जोडू शकता आसण कोणत्याही इतर िुचना दशिवू शकता.
. googleMap.addMarker(new MarkerOptions()
तुम्ही position, title, आसण snippet अशी मासहती जोडली आहे . position मध्ये स्थानाची अक्षां श आसण दे शां तर सदले
आहे , title मध्ये माकिरचं शीषिक, आसण snippet मध्ये माकिरिोबत िं बंसधत िुचना सदली आहे .
आता, तुमचं ऍप मैपवर Marker जोडून िुधाररत केलं आहे . तुम्ही अनेक Marker जोडून त्यां चं स्थान दशिवू
शकता आसण त्यां च्या िाथी इतर इन्टरे प्लक्टसवटीिह िंवाद िाधू शकता.
229 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
(Geocoding) .
(Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain
View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), while
reverse geocoding is the process of converting geographic coordinates
2. Add Permissions: Open your AndroidManifest.xml and add the necessary permissions:
क क क :
Implement Geocoding: Create a method to perform geocoding in your MapsActivity:
// MapsActivity.java
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import android.util.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
230 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
// Perform geocoding
geocodeAddress(" , , ");}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
}
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
} else {
} catch (IOException e) {
e.printStackTrace();
} }}
231 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
( . ) ,
.
// MapsActivity.java
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import android.util.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
232 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
mapFragment.getMapAsync(this);
}
@Override
}
private void reverseGeocodeLocation(double latitude, double longitude) {
try {
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
if (!addresses.isEmpty()) {
Address address = addresses.get(0);
} else {
Log.e("Reverse Geocoding", "No results found");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
233 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Geocoder एक मधील वापरकत्याा ना स्थानाची मासहती िदान करण्यािाठी अिलेली क्लाि आहे . ती सकंवा
सतच्या getFromLocation() आसण getFromLocationName() मेथड् ििह तुम्ही एक स्थानाची मासहती िाप्त करू
शकता.
या मेथडने एक सदलेल्या अक्षां श आसण दे शां तरािाठी स्थानाची मासहती िाप्त करते.
2.getFromLocationName() मेथड:
शकता.
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
setContentView(R.layout.activity_main);
// Example of using Geocoder for reverse geocoding
234 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
try {
List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);
if (!addresses.isEmpty()) {
Address address = addresses.get(0);
} catch (IOException e) {
e.printStackTrace();
}
}
अँडरॉइड वजओकोडर िगश ररव्हसश वजओकोवडां गस ठी पद्धती प्रद न करतो,(methods for reverse geocoding)
Android मध्ये Reverse Geocoding सकंवा स्थानाच्या अक्षां श आसण दे शां तरानुिार स्थानाची मासहती िाप्त करण्यािाठी
Geocoder क्लािचं getFromLocation() मेथड वापरलं जातं. Reverse Geocoding मेथडि चुसकचं अक्षां श आसण
दे शां तर समोवणे आवडतं आहे आसण ते किं काम करतं याचं िराव िदान करतं.
खालीलिमाणे Reverse Geocoding किं काम करतं याचं दाखवतो:
येथे, latitude आसण longitude अिेही तुम्हाला समोसवतलं स्थानाचं अक्षां श आसण दे शां तर. getFromLocation()
मेथडचं सतिचं वापर करून तुम्ही एक List<Address> समोवु शकता. आपल्याला इथे वापरलेलं 1 हे सकती लोकेशंिेि
त्यां ची सवसशष्टता सनसदि ष्ट करण्यािाठी तुम्ही यारेतली getMaxAddressLineIndex() मेथड वापरू शकता. उदाहरणाथि ,
address.getMaxAddressLineIndex() हे त्यां चं पूणि पत्तंग सकतीला लां बंवाचं आहे याचं माप दे ईल.
235 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Example:
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
setContentView(R.layout.activity_main);
// Example of using Geocoder for reverse geocoding
} else {
Log.e("Geocoder", "No results found");
}
} catch (IOException e) {
236 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
e.printStackTrace();
}
हे उदाहरण ररव्हिि सजओकोसडं गिाठी सजओकोडर क्लािचा वापर दाखवते , सनदे शां कां ना मानवी वाचनीय पत्त्यामध्ये
रूपां तररत करते. या उदाहरणात getFromLocation पद्धत वापरली आहे .
API . API
, , .
API .
.
सनसमितीिाठी ऍपमध्ये स्थान िोडवण्याचे कायि करण्यािाठी खालील पदहृमां सकंचे िुचना आहे :
1.स्थान िुचवा:
स्थान वापरण्यािाठी तु मच्या ऍपमध्ये एक MapView वापरा. त्यािाठी, तुम्ही build.gradle फाइलमध्ये Google
2. API की सवनंती:
Google Maps API की सवनंतीिाठी Google Cloud Platform (GCP) वर एक पयाि यी खाते तयार करा. API कीवडि
घेऊन तुम्ही आपल्या ऍपमध्ये स्थान िुचवू इप्लिता अिलेल्या API कीवड्ि ि काढू शकता.
3. Google Maps API कीवड्ि ि जोडा:
तुमच्या AndroidManifest.xml फाइलमध्ये Google Maps API कीवड्ि ि जोडून स्थान िुचवण्यािाठी API कीवडि
नोंदवा.
<application>
<!-- आपली API कीवडि जोडा -->
<meta-data
android:name="com.google.android.geo.API_KEY"
237 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
4. मैप वापरणे:
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:apiKey=" API_kayword "
तुमचं स्थान अक्षां श आसण दे शां तर लाभल्याि, तुम्ही तुमच्या ऍपमध्ये वापरकत्याा िाठी िुरसक्षत वापरण्यािाठी त्याचं
उपयुक्त िेसटं ग करू शकता.
तुमच्या ऍपमध्ये MapView तयार झाल्यानंतर, तुम्हाला तु मच्या कोडमध्ये तुमचे स्थान ठे वण्यािाठी आसण स्थान अपडे ट
करण्यािाठी त्याचं वापर करण्याचं आवश्यक आहे .
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap googleMap) {
}});
238 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
त्यािाठी तुमचं स्थान अक्षां श आसण दे शां तर वापरा आसण तुमचं ऍपमध्ये स्थानाचं मैप दशिवा.आपलं ऍप यारां त
स्थान िोडवण्याची क्षमता अिणे तुमचं ऍप वापरकत्याा ि आपलं ऍप आसण सवसशष्ट क्षेरातील स्थान दशिवण्याि िुधाररत
करू शकेल.
:
1. , Manifest.permission.ACCESS_FINE_LOCATION
Manifest.permission.ACCESS_COARSE_LOCATION .
2. FusedLocationProviderClient .
3. requestLocationUpdates .
4. , .
स्थान ऑब्जेक्ट भौगोसलक स्थानाचे िसतसनसधत्व करते ज्यामध्ये अक्षां श , रे खां श, टाइम स्टॅ म्प आसण इतर मासहती जिे की
बेअररं ग, उं ची आसण वेग यां चा िमावेश अिू शकतो. खालील महत्त्वाच्या पद्धती आहे त ज्या तु म्ही स्थान सवसशष्ट मासहती
मध्ये Location ऑब्जेक्ट हे स्थानाच्या मासहतीिाठी वापरलेलं आहे . जेव्हा तुम्हाला आपल्या ऍपमध्ये
स्थानाचं टर ॅ सकंग करण्याची आवड अिते , तेव्हा तुम्ही Location ऑब्जेक्ट वापरू शकता. खालीलिमाणे , तुम्हाला आपल्या
239 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
API .
Google Map .
, LocationClient , ()
getLastLocation() .
. , −
• GooglePlayServicesClient.ConnectionCallbacks
• GooglePlayServicesClient.OnConnectionFailedListener
connect() .
() () onDisconnected()
- .
( )
, , LocationListener
. ,
( )
LocationClient .
240 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
Example:
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.FragmentActivity;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
setContentView(R.layout.activity_maps);
fusedLocationClient = new FusedLocationProviderClient(this);
mapFragment.getMapAsync(this);
// Check and request location permission
241 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED)
}
else {
}
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Map initialization code...
}
private void startLocationUpdates() {
mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLatLng));
// You can use the current location as needed in your app
}
}
242 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
}, null);
}
fusedLocationClient.removeLocationUpdates(new LocationCallback());
}
@Override
protected void onDestroy() {
super.onDestroy();
stopLocationUpdates();
}
private static int UPDATE_INTERVAL = 5000; // 5 seconds
locationRequest.setFastestInterval(FASTEST_INTERVAL);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
return locationRequest;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull
int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == LOCATION_PERMISSION_REQUEST_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
// Permission denied, handle accordingly
243 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
} } }}
.
ACCESS_FINE_LOCATION ACCESS_COARSE_LOCATION
, :
1.स्थान िेवा स्वीकृती:
तुमच्या अॅपला स्थान िेवा स्वीकृती दे णे आवडे ल. त्यािाठी AndroidManifest.xml फाइलमध्ये खालील इम्पोटि
जोडा:
2. LocationManager वापरणे:
तुमच्या एप्लिकेशनमध्ये LocationManager चा वापर करून स्थान तपािण्याि िुरुवात करा
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) ==
PackageManager.PERMISSION_GRANTED) {
// स्थान िेवा िक्षम आहे
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
} else {
String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
.
1. :
, .
.
2. :
.
, .
3. :
. ,
,
.
245 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
4. - :
- ,
.
5. Google Play Protect:
.
6. ट:
,
. , ,
.
7. (HSM):
६.१२
,
. :
1. :
2. :
.
.
3. ट :
.
4. - (Secure Elements):
(SIM, ) - .
.
246 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
5. (KeyStore):
, KeyStore .
6. टक टक :
,
.
7. ट ट :
,
.
8. ट:
9. Android Enterprise:
Android Enterprise
६.१३
,
(permissions) . .
permissions :
Permissions:
1. INTERNET:
: .
: , - .
2. ACCESS_NETWORK_STATE:
: .
: , .
3. READ_EXTERNAL_STORAGE:
: .
: SD , .
4. WRITE_EXTERNAL_STORAGE:
247 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
: .
: SD , .
5. CAMERA:
: .
: , .
6. READ_CONTACTS:
: .
: , .
7. WRITE_CONTACTS:
: .
: , .
8. ACCESS_FINE_LOCATION:
: .
: GPS , .
9. ACCESS_COARSE_LOCATION:
: .
: , .
10. CALL_PHONE:
: .
: .
11. SEND_SMS:
: SMS .
: .
12. RECEIVE_SMS:
: SMS .
: .
248 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
६.१४ घ क
permissions .
AndroidManifest.xml . ,
.
AndroidManifest.xml :
1. ट ट :
<uses-permission android:name="android.permission.INTERNET" />
1. क :
<uses-permission android:name="android.permission.READ_CONTACTS" />
2. क :
<uses-permission android:name="android.permission.CAMERA" />
3. :
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
4. SMS :
<uses-permission android:name="android.permission.SEND_SMS" />
5. permissions :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
.
:
import android.Manifest;
import android.content.pm.PackageManager;
import androidx.core.app.ActivityCompat;
import androidx.appcompat.app.AppCompatActivity;
249 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
setContentView(R.layout.activity_main);
//
requestContactsPermission();
}
private void requestContactsPermission() {
//
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) !=
PackageManager.PERMISSION_GRANTED) {
} else {
// , ( )
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull
int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == CONTACTS_PERMISSION_CODE) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// ,
// ( )
} else {
// , , ( . )
} } }}
250 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
permissions
.
, permissions permissions
. permissions permissions ,
permissions permissions .
, , CALL_PHONE ,
permissions :
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import androidx.core.app.ActivityCompat;
Manifest.permission.CALL_PHONE,
Manifest.permission.READ_PHONE_STATE
};
public static boolean requestPhonePermissions(Context context)
{
for (String permission : PHONE_PERMISSIONS) {
if (ActivityCompat.checkSelfPermission(context, permission) !=
PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions((YourActivity) context, PHONE_PERMISSIONS,
PHONE_PERMISSIONS_REQUEST_CODE);
return false;
251 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
}
}
return true;
}
}
PermissionUtil , permissions
permissions .
.
, APK KeyStore .
KeyStore .
, Android Studio .
Android Studio .
१. KeyStore क :
Android Studio .
KeyStore KeyStore .
२. KeyStore क Android Studio :
Android Studio .
"File" > "Project Structure" > "Signing" .
३. क क :
Android Studio .
252 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
!
KeyStore .
.
, .
1. क :
Google Play Console .
2. क :
.
Google Play .
3. क,क क :
.
4. क :
.
5. क क :
.
"Create Application" .
.
6. क :
, , .
.
.
7. APK क :
Play "Release" .
"Create Release" .
APK .
8. टक :
, , , .
, .
253 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
,
. Google
.
, , Google Play
. , ,
.
६.१९ क
Google Play Store
. :
१. क :
क टक :
.
२. क ट:
क ट: , , .
क : , .
३. :
:
.
: .
४. :
254 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
क :
.
: .
५. :
क : , .
क ट : .
६. :
:
.
. .
Google Play Store :
Google Google .
२. क क :
Play Console .
३. Google Play Console क :
255 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI
Mobile Application Development (22617) (२२६१७)
५. क ट क :
, , .
६. क :
.
७. क क क :
सांदभशसूची(Bibliography)
१ https://www.geeksforgeeks.org/google-maps-in-android/
२ https://developer.android.com/studio/publish
३ https://developer.android.com/distribute/console
४ https://www.tutorialspoint.com/android/android_sending_sms.htm
५ https://developer.android.com/reference/android/widget/ZoomControls
६ https://www.tutorialspoint.com/android/android_location_based_services.htm
256 | Page
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION ,MUMBAI