صفحه 1:
Programming the Android Kristopher Micinski, Secretary, ACM Chapter, MSU ACM Fall Activity Series, 2010 October 21s, 2010

صفحه 2:
Welcome! Welcome to the first talk in the 26 ‏ل‎ series for ۴۵۱۱ 2 ۳ =i) 0 0 0 ‏م ا‎ lecture. But there’s pizza ‏یر‎ ‎0 ‏عم‎ ‎The goal of the Activity ‏ت۱۱‎ اك ا وت ات رات کل ‎you‏ ‏5دة مأ تا رت ۱9 ل اك ا تنا time or don’t directly relate .81م عط مغ it mi Fu ISK eee 50 301/ 01 ‏لانا0ننا 35ع10 ناولا‎ ۳ 5 really help for future events: | Yeudon’t get the software = 0 اروت یات بت از 0 ا ۷۴ ۲6۵۱۷ ۱

صفحه 3:
Outline of the talk * Today we're talking about how to write applications on the Android operating system. ‏توا‎ ‎» What makes mobile application development different? » A broad overview of the Android approach. * Android programming: » Covering the three basic classes: ٠ ‏5ع ا ألاناعم‎ cast ale} ۱3۳ ‏یر‎ Nes » Example application: ۱ ‏روت ترتع‎ ۱۵ ‏ار‎ » Hopefully you get a broad overview of the system, but you'll have to go read about / play around with the sample code and experiment to understand more.

صفحه 4:
560110 [1 Introduction, Mobile Programming, Android Tale

صفحه 5:
Why is mobile programming different? * So why can’t we just put * Mobile devices have increased RAM daily, so why don’t we wait until we have enough? » Easy answer, we never will * Harder answer: *» ‏5ععءمعرع]7 أل ع0‎ 00. ie TiC ‏تال دا‎ other big companies give you the tool chain. » The API is restricted: Sera eRe nC) ‏غلا0 ]أنه غ»اع] عن 0388 0مع5‎ ‏ل‎ ‎0 ‏دی ات‎ Ud ‏ع)۷ع0‎ t ura) our desktop code on a mobile device verbatim? ۶25۷ ۵05۷۷6۲: ۵۵6 06۷۱6۵5 ۱۵۷۶ ۳۲ types 0۲ ۲65۵۷۲۵5 (RAM, long term storage, etc...) than your laptop. Slightly more difficult 2۲ * The field is moving ۰ ‏کف‎ ON Lae companies are ‏را یام ات یاه‎ 8 Consequence: ‏ا‎ 6 specific to devices.

صفحه 6:
Practical Matters... * You'll write your code in Java, and using the android API. * It might not do everything you want! » [had to write my own class to output DOM based XML. » Also, it changes, your app might require the newer APIs. ۱ ‏هرت‎ OTe (- ‏4ات‎ » Uses Eclipse for the IDE, you might be able to get VS to work? ٠ A few basic classes, then lots of smaller utility classes: ۱۳ ‏لأمعلمط وس ین‎ (6 * | strongly encourage you to do the following: * Go through the slides in this talk first, and then the sample application. * Go to the Android developer documentation, and read through the main pages / classes. ٠» Start working on your own applications, and then when you get stuck, read the documentation

صفحه 7:
Installing the SDK http://developer.android.com/sdk/installing.html ٠ ‏عاعأنان ة عنذذو 11"ا غناط ,كلد هل مع عامط اتهاعل برطغومعا مأ دعطزعدع0‎ ‏هن‎ First download Eclipse: Bes onal ee | Next, download the Android SDK: Bee Meee ecu Rees eater Unzip the SDK and run the SDK manager in the directory you unzip, then install all of the extra required packages, etc... ۱: ge om te) Cee MU ‏هک‎ lots of samples, documentation, and more! Create a new virtual device so that you can run an emulator. 8 ‏ا‎ go into eclipse and download the Android developer leo Prcero Se isc ner nC CR rao inne ts + https://dl-ssl.google.com/android/eclipse/ 0 tose cena Denk tiles] You should be good to go from here! Try doing a New->Project and selecting a sample application!

صفحه 8:
Section II Basic Android programming overview

صفحه 9:
The Android Approach For each distinct logical piece of program behavior OTR TR 8 [303 ‏355ء‎ 00 from a base flO Activities: Things the user >80 5۵6 00 16 ۰ Basically, each different ‎Tu‏ ات یات وت ‎Services: Code that isn’t ‎associated with a screen ‎(background, fairly ‎common) ‎60۳6۳ ۱ ۱۷۱ ۱/۱5 ‎Provides an interface to ‎exchange data between rograms (usually SQL ased) ‎Beem CUCM atau) ‏تا ‏بعالا اعلوالا عط مه ل0ع5ة8 ‎٠‏ ‏۰ و0651 020۴۲۲۵۱۱6۲ ‎Don’t think of your program‏ * یت ات ات ات ‎Op aS ۳ ela eta) ‏تست‎ ‏ات‎ ‎* The blocks communicate back and forth via message passing, etc... ‎* Added advantage, physical ‏رت یر ات۳‎ Ie eRe esd ‏ا یت یا‎ same programming ‏یت‎ ‎0 ‎0] ‏ممة عط أه كعععام أمعرع‎ 6 cee Tr Cee nce Ie nt

صفحه 10:
* The activity allows you to set the top level GUI ‎Lally‏ كت ‎1 ‏رت ترا ناملا معط‎ leat? ‎Views (widgets), put them ‎Rolla eda eels ‏35 أعلأوغاممء ع5 أع5 ‎Activity’s top level View: ‎Bee oreo) ‏وه‎ see eR 6 Nain ren ‏مه لامعل مأ هما مو دمن عللا + كه ,قمع ومأصصقءومعم الات لك ‎The Activity is loaded by ‎the Android OS, then the ‎appropriate methods are ‎called based on user ‎interaction (back button?) ‎Activities ‎Activities describe ‏لكل یت‎ ‏حك للا‎ omy interacting. Your program specifies a top level screen that runs upon application startup. Each Activity performs its own actions, to execute a method in another Activity use an /ntent. "۲06 ۸۷۱۵ ‏355اء ععوط‎ 22 ‏لت ی‎ enough functionality to Maeve alo “does nothing” See CoN RTRs ‎6801/35! ‎00

صفحه 11:
The evolution of a Activity ۲۳6 ۸۷۷۱۵ ۱25 2 number of predefined functions that you override to handle events from the system. If you don’t specify what should be done the 2 ۰ ‏ات۱۱ ریت‎ ‏1005غ36 غاناهاء0‎ 0 handle events. Why would you want to ‏ریت ت1۱‎ onPause(), etc... ? You will probably want to 00 ‏ع35عاع] عاذ دكوصاط‎ resources, stop network ‏...ع ینت۱‎

صفحه 12:
Steps to developing an Activity ‎Specify a default View‏ * ل ا تت ات لا ‎ ‎for the Activity. ‎In the onCreate ‎۹۹ ‏ات‎ set up ‎handlers for your ‎View’s actions: ‏۲ 0۴ ۵ اع5 « 7مغناط 5000 101 ‎Find out what other ‎Activities you want to ‎ir] aon ‎When do you want to ‎change screens? ‏ما هو ,۵۵۳۵۱6 ۲۴۵۲ ‎PassportBrowser from ‎DocumentDisplay. ‏۰ 20 وبا ۲60 ‎your project, using ‎Activity as a base class. * Then override ‎onCreate(), ‎onResume(), etc... as you need! ‎* Put your Activity in the android manifest. ‎0 ‏ليك ان ا لل‎ specifies the different classes in your 9 what ‏“لت 0 تايا‎ Sag interact. ‎]2- ob caged Clee 6۵0 6 Eclipse to fill this out for ‏ناولا‎

صفحه 13:
User starts yo Intents ‏م‎ How does an Activity (or any Crt aE ee UY lie) ‏کت ت۱0‎ Ed ۳۳-۳ ‏عدن عللا‎ eon) ‏ل‎ ‎0 ine Kia Sunes eee cnr aC MC RuCl ‏ه) عغمهع0مه كأ كقط لاأباناعم‎ onResume, etc...) method called. ‏ارت ییا‎ R ‏ا‎ ‎peace erecta ‏یی‎ onCreate() 0 0 0 ‏ممع 1اممة عناملا‎ ‏1ت‎ MUR) ‏قت اش رتنیا‎ ‏ار‎ | User clicks on an object to edit ba عدوا تعمد لمع عط 6 Bs gts ان عناملا برط فععهدى ممه دمماع تومه بطر نعط عب

صفحه 14:
User selects item to download Services 56۳۷66 0۳۵۷06 2 ۷/۵۷ ۲ your application to handle events in the background, without being explicitly 1 ivi ‏ات یت‎ Pris a View. ‏نات‎ ‏تیا ذ5عءالااع5 ,إع لاع بالاولا‎ 1 ‏إلقعقط دنلده عأعطغ مأ علأوعم‎ Activity asks eRe (aaa Re Ld 56۳۷۱۵ 0 ‏ال‎ ۳ 56۲۷۱6۵, ۷۵۱ ۷۱۱ ۵ ‏رن‎ ۳ fare ‏هأي) معنا‎ ‎ITD‏ تام ل ليل ات انا ‎do?‏ ‏3ك ‎in currently running‏ ‎activity‏ ‎ee 3 ‎ ‎BV tata ‏ما عوداه‎ ‏ا ري‎ NTR (oe <la tile Cree Rater ٠ ‏متهم م اعه6 الف مدع‎ Praia re Narula 6855 ‎Downloading Threads (maybe thread ۱0017(

صفحه 15:
Storing long term data * The best solution is to use ‏م ععوأمعاما لأمءصط عط‎ SQLite: 1 eee) on SQL Segue nese Poesia a no ‏كك‎ cele 0 * ‏ناولا‎ make queries to the database in standard SQL: ‏ت۹1‎ FROM STATION WHERE ‏آها‎ ۱۱ < 7” ٠ ‏مملنوعذاممة عناملا معط‎ provides a handler to Interface the SQL database to other applications via a content provider: Bere et و رد۱ مأ 038 ات رت 0100131 اناولا ع0 وا 6۵0 ناملا ‎Vir Teemu}‏ ‎to store simple key-value‏ ‎pairs‏ ‏لل ‏0 66 ۱۵150۵۲6۵۴۲۵۲۵۲6 ‎then use call getString,‏ ...عق ,8001620عو ‎However, you'll probably‏ ‎NEU Reena‏ ‎complicated storage.‏ تک ۱ تیا ۱ تا ات ات 0010م ‎storage‏

صفحه 16:
Content Providers For example, let’s say we want our content ‏ا‎ oa Ls applications to access our database of bicycles 300 3150 515. We define methods for ‏,وط۲عکطا‎ 061609, updating, etc... bicycles and customers. Then we publish two 1H * BICYCLES URI ‏ل ریت۱9‎ Maybe more URIs for accessing bicycles indexed by serial ‎tata‏ یی ‎60۳0۵۲ ۵ abstract data storage to other applications, 1۳۶۱ ‏ات توت رت‎ Again, fairly SQL based. ۱۸/۱ ‏أعناءغكمم‎ 3 )00۲۵۱۲۴۳۵۷۱۵۵۲ ‏ووجا)‎ ‏تور‎ ‎methods such as insert(), delete(), and update(). ‎Then you register your content provider with a URI to handle different types of objects. ‎BU ean ieN tag (kind of like a URL)

صفحه 17:
So, how do I design my * Think about what background Services you ‏ا‎ iatecela stele oe ۱2 0 ‏ل‎ tet ants eee NASM et ae ی ی یناکت را ریت ۳ * Think about what information must be stored in long term memory and design a content provider around it. baa oN more lat =Leimi sal} ۱۵ ۹۳ ( ‏رهز‎ (etre ‏...عع‎ ‎Tita) cha * Don’t forget good OOP © * ‏عط1‎ Co aS) 218-1 architecture is set up if fairly open: See aan somewhat up to you, but ‘ou still have to live with ۱۳ ۱ model. لل ات لل تل كت ‎screens that the user‏ خلركا ا ححا اننا اج ۸۲۷۵۵5 01۲۲6۲6۲ ‎will comprise your‏ ‎Vaca‏ ‎Think about the‏ عط دمع نمع ار رتیل ید۱ ‎screens, these will be the‏ ‎intents passed between‏ .5ع أ/اتاعم عا

صفحه 18:
Section III Sample Application: MSU Cafeteria Menu ‏وح كينا‎

صفحه 19:
Designing our first Android App * We want to design an application to view the menus for the MSU cafeterias. * What is involved with this? What objects do we have to deal with? ‏ری‎ iL} ۰ ۸۵ ‏داعاهآی‎ ‎» An internet connection? + For this application, I’m going to use the ListActivity: * This is an Activity with a top level container to display a ۱8 ‏باع هعم موء معدن رش رل‎ ۰ What background services are we going to need ‏لتكتلا‎ ‎« I'm just going to use a thread here, not enough work to set up an activity

صفحه 20:
What type of input do we have? * Let’s visit http://www.eatatsate.com to find out! ٠ ‏علالا‎ a ‏عع مانام 3 غععاع5 مقع علا أهطغ ععد‎ 06 different cafeterias: « Probably going to stick with this interface, so the main Activity of our application will let us select cafeterias. * With each of those cafeterias we see that we can have a number of different stations: » So down in the hierarchy the user will select the station in which they are interested. * For each cafeteria we have an RSS feed describing the current cafeteria menu. » So we'll need to keep track of what cafeterias go with what RSS feeds (URLS)

صفحه 21:
eas tations link in browser. download meu in ferent) Rear e ee مه كاعذاء معدلا تفت ةا عا مومع وعاقعى که اه زناه ۱۰۱۵ عفده)رروو ‎eee‏ ماه عطا من 6) ‎rere‏ عا جععتوم مونعهه ey 1

صفحه 22:
What next? What should you do now? Go download the Android SDK, even if you don’t have an PUM eee eet ee Then download the sample application and go through. Set breakpoints at onCreate() and onResume() on the main .که )201۷ مغ وماغوءأصنتصصمم وم ابعل وبنط وبطعل معنك مق نهل مع ووبطعل عءألر + ‎Ng‏ یا کارت ۱۹/۰ in the documentation and read the docs on the classes | ‏زیت خلت یا‎ Be careful, pressing “next” in the debugger doesn’t always mean you will go to the next line. Sometimes you will fall into an Android binary class, so set lots of breakpoints. Now try to modify the demo application: * Add caching! Se ‏ما تپ‎ RRC Rae ela ‏ایلاتیا‎ eR Relea Cue ‏ا‎ aon Cre roe Se CCM a eck creer ke eet eM yt Fer asl ۱ ‏کت وین وتات زا یت رک ت رت‎ eal] ‏كان‎

صفحه 23:
Thanks! ٠ Thanks for coming to the first in the ACM Activity Tat * Maybe some still free pizza, grab some. * Be sure to talk to me and tell me if you had any comments or questions » Also, we're going to use the ACM Listserv to support 0۳ عع ۱۳۰ 06 > ۲۸5 ۰ . ۳۳ 5

جهت مطالعه ادامه متن، فایل را دریافت نمایید.
29,000 تومان