barnameh_nevisiye_android

در نمایش آنلاین پاورپوینت، ممکن است بعضی علائم، اعداد و حتی فونت‌ها به خوبی نمایش داده نشود. این مشکل در فایل اصلی پاورپوینت وجود ندارد.




  • جزئیات
  • امتیاز و نظرات
  • متن پاورپوینت

امتیاز

درحال ارسال
امتیاز کاربر [0 رای]

نقد و بررسی ها

هیچ نظری برای این پاورپوینت نوشته نشده است.

اولین کسی باشید که نظری می نویسد “Programming the Android”

Programming the Android

اسلاید 1: Programming the AndroidKristopher Micinski, Secretary, ACM Chapter, MSUACM Fall Activity Series, 2010October 21st, 2010

اسلاید 2: Welcome!Welcome to the first talk in the ACM Activity series for Fall 2010:Okay, so this one is more of a lecture. But there’s pizza over there.The goal of the Activity series is to cover topics that you might be interested in, but won’t cover in class because they take too much time or don’t directly relate to the material.So any of your ideas would really help for future events:LaTeX?Linux kernel internals.How does your toolchain really work?An introduction to F#.Believe it or not, when you search Google for LaTeX, you don’t get the software package…

اسلاید 3: Outline of the talkToday we’re talking about how to write applications on the Android operating system.First:What makes mobile application development different?A broad overview of the Android approach.Android programming:Covering the three basic classes:ActivitiesServicesContent providersExample application:MSU Cafeteria menusWhat should I take out of the talk?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: Section IIntroduction, Mobile Programming, Android overview

اسلاید 5: Why is mobile programming different?So why can’t we just put our desktop code on a mobile device verbatim?Easy answer: mobile devices have different types of resources (RAM, long term storage, etc…) than your laptop.Slightly more difficult answer:The field is moving quickly, driven by industry, companies are driven by time to market.Consequence: APIs are specific to devices.Mobile devices have increased RAM daily, so why don’t we wait until we have enough?Easy answer, we never willHarder answer:Other differences too.Device manufacturers or other big companies give you the tool chain.The API is restricted:Don’t want a program to send data or text without your knowledge!User interaction is different on a mobile device (small screen?)

اسلاید 6: Practical Matters…You’ll write your code in Java, and using the android API.It might not do everything you want!I had to write my own class to output DOM based XML.Also, it changes, your app might require the newer APIs.The SDK, emulator, etc... Is all free!Uses Eclipse for the IDE, you might be able to get VS to work?A few basic classes, then lots of smaller utility classes:Some classes are Android specificI 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 SDKhttp://developer.android.com/sdk/installing.htmlDescribes in lengthy detail how to do this, but I’ll give a quick overview.First download Eclipse:http://www.eclipse.org/Next, download the Android SDK:http://developer.android.com/sdk/index.htmlUnzip the SDK and run the SDK manager in the directory you unzip, then install all of the extra required packages, etc…Be sure to poke around in the SDK directory, there are lots of samples, documentation, and more!Create a new virtual device so that you can run an emulator.Then go into eclipse and download the Android developer tools:Go to Help->Install new software… and add the following URLhttps://dl-ssl.google.com/android/eclipse/Now add a new name (just make one up?) and downloadYou should be good to go from here! Try doing a New->Project and selecting a sample application!

اسلاید 8: Section IIBasic Android programming overview

اسلاید 9: The Android ApproachBased on the Model View Controller design pattern.Don’t think of your program as a linear execution model:Think of your program as existing in logical blocks, each of which performs some actions.The blocks communicate back and forth via message passing, etc…Added advantage, physical user interaction (screen clicks) and inter process interaction can have the same programming interfaceAlso the scheduler can bring different pieces of the app to life depending on memory needs and program useFor each distinct logical piece of program behavior you’ll write a Java class (derived from a base class).Activities: Things the user can see on the screen. Basically, each different screen in your program.Services: Code that isn’t associated with a screen (background, fairly common)Content providers: Provides an interface to exchange data between programs (usually SQL based)Kind of vague, but we’ll given an example.

اسلاید 10: ActivitiesActivities describe individual screens with which a user could be 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 Intent.The Activity base class already provides you with enough functionality to have a screen which “does nothing”Provides you with an empty canvas!No pun intended…The activity allows you to set the top level GUI container.Then you instantiate some Views (widgets), put them in a container View, and set the container as the Activity’s top level View:This is what gets displayed on the screen when the Activity is running.We won’t go too in depth on GUI programming here, lots of documentation.The Activity is loaded by the Android OS, then the appropriate methods are called based on user interaction (back button?)

اسلاید 11: The evolution of a ActivityThe Activity has a number of predefined functions that you override to handle events from the system.If you don’t specify what should be done the system will perform the default actions to handle events.Why would you want to handle events such as onPause(), etc… ?You will probably want to do things like release resources, stop network connections, etc…

اسلاید 12: Steps to developing an ActivityCreate a new class in your project, using Activity as a base class.Then override onCreate(), onResume(), etc… as you need!Put your Activity in the android manifest:This is a file that specifies the different classes in your app, what they do, and how they interact.Easiest to see examples of this, or you can use Eclipse to fill this out for you.Specify a default View for the Activity.In the onCreate (usually) you set up handlers for your View’s actions:Set an onClick handler for some button?Find out what other Activities you want to talk to:When do you want to change screens?For example, go to PassportBrowser from DocumentDisplay.Then use an Intent…

اسلاید 13: IntentsHow does an Activity (or any other runnable Android object) get started?We use the Intent class to ask the Android OS to start some Activity, Service, etc…Then the OS schedules that Activity to run, and that Activity has its onCreate (or onResume, etc…) method called.Intents are used to represent most inter-process requests in Android:Dialing a numberSending a textStarting a new Activity within your applicationSo the system will generate Intents, and so will your app!BrowseContents RunningEditContent runningUser clicks on an object to editIntent object to start the EditContent ActivityNew()User starts your app!Intent object to start the EditContent ActivityonCreate()setClass()onCreate()User clicks back buttononRestart()Notice! Here the red transitions are the events initiated by the Android OS, and the green transitions are created by your application!

اسلاید 14: Downloading Threads (maybe thread pool?)ServicesServices provide a way for your application to handle events in the background, without being explicitly associated with a View.However, services don’t reside in their own thread!So don’t perform things like network connections in a service, you will block the main thread!However, what can you do?Use your Service class to provide an interface to a background threadCan call back to main activity using a Handler class Main ActivityServiceonButtonClick() called in currently running activityActivity asks Service to download specific item (via an intent!) Worker Thread(downloading)New worker threadDone downloading!(new WorkerThread()).start()User selects item to download

اسلاید 15: Storing long term dataEventually you’ll want to store long term data in your program.You can use the SharedPreferences class to store simple key-value pairsSimple interface, call getSharedPreferences and then use call getString, getBoolean, etc…However, you’ll probably want to use more complicated storage.Android provides an SQLite interfaceAlso ContentProviders provide inter process data storageThe best solution is to use the Android interface to SQLite:Lightweight database based on SQLFairly powerful, can’t notice the difference between SQLite and SQL unless you have a large databaseYou make queries to the database in standard SQL:“SELECT ID, CITY, STATE FROM STATION WHERE LAT_N > 39.7;”Then your application provides a handler to interface the SQL database to other applications via a content provider:Look at an example!

اسلاید 16: Content ProvidersContent providers abstract data storage to other applications, activities, services, etc…Again, fairly SQL based.You will construct a ContentProvider class that will override methods such as insert(), delete(), and update().Then you register your content provider with a URI to handle different types of objects.Unique Resource Identifier (kind of like a URL)For example, let’s say we want our content provider to allow other applications to access our database of bicycles and also customers.We define methods for inserting, deleting, updating, etc… bicycles and customers.Then we publish two URIs:BICYCLES_URICUSTOMERS_URIMaybe more URIs for accessing bicycles indexed by serial number?

اسلاید 17: So, how do I design my program?The way the system architecture is set up if fairly open:Program design is somewhat up to you, but you still have to live with the Android execution model.Start with the different screens that the user will see. These are the different Activities that will comprise your system.Think about the transitions between the screens, these will be the Intents passed between the Activities.Think about what background Services you need to incorporate.Exchanging dataListening for connections?Periodically downloading network information from a server?Think about what information must be stored in long term memory and design a content provider around it.Now connect the Activities, services, etc… with Intents!Don’t forget good OOP 

اسلاید 18: Section IIISample Application: MSU Cafeteria Menu Browser

اسلاید 19: Designing our first Android AppWe 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?A menuA cafeteriaAn internet connection?For this application, I’m going to use the ListActivity:This is an Activity with a top level container to display a list with which the user can interact.What background services are we going to need here?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!We can see that we can select a number of 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: Our program designMainScreen(Activity)CafeteriasContentProviderMenuDownloadingThreadonResume() create a new thread to download menu in the backgroundFetch the list of cafeterias in the databaseUser clicks on cafeteria to browseIntent: passes cafeteria name and URLCafeteriaBrowser(Activity)CafeteriabrowsingCafeteria1Downloads the XML from the URL, parses it, and creates a fills up the Cafeteria object as needed.(What design pattern is this?)Downloading Complete! (Message)CafeteriaMenuDownloaderNew()Android BrowserUser selects station to browse, navigate to that stations link in browser.CafeteriaStation1*

اسلاید 22: What next?What should you do now?Go download the Android SDK, even if you don’t have an android phone this can still be fun!Then download the sample application and go through. Set breakpoints at onCreate() and onResume() on the main activities.Nice debugger. You can even debug two devices communicating to each other at the same time over Bluetooth on the same computer!Dig around in the documentation and read the docs on the classes I mentioned.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!Create a “add new cafeteria” Activity that allows you to enter a title and URL of the RSS feed for cafeterias and add new ones to the database.Add a way to delete cafeterias from the database, maybe automatically delete them after the connection does not work for a while?

اسلاید 23: Thanks!Thanks for coming to the first in the ACM Activity series!Maybe some still free pizza, grab some.Be sure to talk to me and tell me if you had any comments or questionsAlso, we’re going to use the ACM Listserv to support answers to questions for these events. Send your questions there.Join the MSU ACM Chapter!

29,000 تومان

خرید پاورپوینت توسط کلیه کارت‌های شتاب امکان‌پذیر است و بلافاصله پس از خرید، لینک دانلود پاورپوینت در اختیار شما قرار خواهد گرفت.

در صورت عدم رضایت سفارش برگشت و وجه به حساب شما برگشت داده خواهد شد.

در صورت بروز هر گونه مشکل به شماره 09353405883 در ایتا پیام دهید یا با ای دی poshtibani_ppt_ir در تلگرام ارتباط بگیرید.

افزودن به سبد خرید