首页 > > > Programming Android.pdf

Programming Android.pdf

Programming Android.pdf

上传者: 陆永 2011-10-13 评分1 评论0 下载54 收藏10 阅读量1023 暂无简介 简介 举报

简介:本文档为《Programming Androidpdf》,可适用于软件工程领域,主题内容包含ProgrammingAndroidProgrammingAndroidZigurdMednieks,LairdDornin,GBlakeMeike符等。

ProgrammingAndroidProgrammingAndroidZigurdMednieks,LairdDornin,GBlakeMeike,andMasumiNakamuraBeijing•Cambridge•Farnham•Köln•Sebastopol•TokyoProgrammingAndroidbyZigurdMednieks,LairdDornin,GBlakeMeike,andMasumiNakamuraCopyrightZigurdMednieks,LairdDornin,GBlakeMeike,andMasumiNakamuraAllrightsreservedPrintedintheUnitedStatesofAmericaPublishedbyO’ReillyMedia,Inc,GravensteinHighwayNorth,Sebastopol,CAO’Reillybooksmaybepurchasedforeducational,business,orsalespromotionaluseOnlineeditionsarealsoavailableformosttitles(http:mysafaribooksonlinecom)Formoreinformation,contactourcorporateinstitutionalsalesdepartment:()orcorporateoreillycomEditors:AndyOramandBrianJepsonProductionEditor:AdamZarembaCopyeditor:AudreyDoyleTechnicalEditors:VijaySYellapragadaandJohanvanderHoevenProofreader:SadaPreischIndexer:LucieHaskinsCoverDesigner:KarenMontgomeryInteriorDesigner:DavidFutatoIllustrator:RebeccaDemarestPrintingHistory:July:FirstEditionNutshellHandbook,theNutshellHandbooklogo,andtheO’ReillylogoareregisteredtrademarksofO’ReillyMedia,IncProgrammingAndroid,theimageofapinegrosbeak,andrelatedtradedressaretrademarksofO’ReillyMedia,IncManyofthedesignationsusedbymanufacturersandsellerstodistinguishtheirproductsareclaimedastrademarksWherethosedesignationsappearinthisbook,andO’ReillyMedia,Inc,wasawareofatrademarkclaim,thedesignationshavebeenprintedincapsorinitialcapsWhileeveryprecautionhasbeentakeninthepreparationofthisbook,thepublisherandauthorsassumenoresponsibilityforerrorsoromissions,orfordamagesresultingfromtheuseoftheinformationcontainedhereinISBN:LSITableofContentsPrefacexiiiPartIToolsandBasicsYourToolkitInstallingtheAndroidSDKandPrerequisitesTheJavaDevelopmentKit(JDK)TheEclipseIntegratedDevelopmentEnvironment(IDE)TheAndroidSDKAddingBuildTargetstotheSDKTheAndroidDevelopmentToolkit(ADT)PluginforEclipseTestDrive:ConfirmThatYourInstallationWorksMakinganAndroidProjectMakinganAndroidVirtualDevice(AVD)RunningaProgramonanAVDRunningaProgramonanAndroidDeviceTroubleshootingSDKProblems:NoBuildTargetsComponentsoftheSDKTheAndroidDebugBridge(adb)TheDalvikDebugMonitorServer(DDMS)ComponentsoftheADTEclipsePluginAndroidVirtualDevicesOtherSDKToolsKeepingUptoDateKeepingtheAndroidSDKUptoDateKeepingEclipseandtheADTPluginUptoDateKeepingtheJDKUptoDateExampleCodeSDKExampleCodeExampleCodefromThisBookOnReadingCodevJavaforAndroidAndroidIsReshapingClientSideJavaTheJavaTypeSystemPrimitiveTypesObjectsandClassesObjectCreationTheObjectClassandItsMethodsObjects,Inheritance,andPolymorphismFinalandStaticDeclarationsAbstractClassesInterfacesExceptionsTheJavaCollectionsFrameworkGarbageCollectionScopeJavaPackagesAccessModifiersandEncapsulationIdiomsofJavaProgrammingTypeSafetyinJavaUsingAnonymousClassesModularProgramminginJavaBasicMultithreadedConcurrentProgramminginJavaSynchronizationandThreadSafetyThreadControlwithwait()andnotify()MethodsSynchronizationandDataStructuresTheIngredientsofanAndroidApplicationTraditionalProgrammingModelsComparedtoAndroidActivities,Intents,andTasksOtherAndroidComponentsServiceContentProvidersBroadcastReceiverStaticApplicationResourcesandContextApplicationManifestsATypicalSourceTreeInitializationParametersinAndroidManifestxmlResourcesTheAndroidApplicationRuntimeEnvironmentTheDalvikVMZygote:ForkingaNewProcessSandboxing:ProcessesandUsersComponentLifeCyclesvi|TableofContentsTheActivityLifeCyclePackaginganAndroidApplication:TheapkFileOnPortingSoftwaretoAndroidGettingYourApplicationintoUsers’HandsApplicationSigningPublicKeyEncryptionandCryptographicSigningHowSignaturesProtectSoftwareUsers,Publishers,andSecureCommunicationsSigninganApplicationPlacinganApplicationforDistributionintheAndroidMarketBecominganOfficialAndroidDeveloperUploadingApplicationsintheMarketGettingPaidGoogleMapsAPIKeysSpecifyingAPILevelCompatibilityCompatibilitywithManyKindsofScreensTestingforScreenSizeCompatibilityResourceQualifiersandScreenSizesEclipseforAndroidSoftwareDevelopmentEclipseConceptsandTerminologyPluginsWorkspacesJavaEnvironmentsProjectsBuildersandArtifactsExtensionsAssociationsEclipseViewsandPerspectivesThePackageExplorerViewTheTaskListViewTheOutlineViewTheProblemsViewJavaCodinginEclipseEditingJavaCodeandCodeCompletionRefactoringEclipseandAndroidPreventingBugsandKeepingYourCodeCleanStaticAnalyzersApplyingStaticAnalysistoAndroidCodeLimitationsofStaticAnalysisEclipseIdiosyncrasiesandAlternativesTableofContents|viiEffectiveJavaforAndroidTheAndroidFrameworkTheAndroidLibrariesExtendingAndroidOrganizingJavaSourceConcurrencyinAndroidAsyncTaskandtheUIThreadThreadsinanAndroidProcessSerializationJavaSerializationParcelableClassesThatSupportSerializationSerializationandtheApplicationLifeCyclePartIIAbouttheAndroidFrameworkBuildingaViewAndroidGUIArchitectureTheModelTheViewTheControllerPuttingItTogetherAssemblingaGraphicalInterfaceWiringUptheControllerListeningtotheModelListeningforTouchEventsListeningforKeyEventsAlternativeWaystoHandleEventsAdvancedWiring:FocusandThreadingTheMenuFragmentsandMultiplatformSupportCreatingaFragmentFragmentLifeCycleTheFragmentManagerFragmentTransactionsTheCompatibilityPackageDrawingDandDGraphicsRollingYourOwnWidgetsLayoutCanvasDrawingviii|TableofContentsDrawablesBitmapsBlingShadows,Gradients,andFiltersAnimationOpenGLGraphicsHandlingandPersistingDataRelationalDatabaseOverviewSQLiteTheSQLLanguageSQLDataDefinitionCommandsSQLDataManipulationCommandsAdditionalDatabaseConceptsDatabaseTransactionsExampleDatabaseManipulationUsingsqliteSQLandtheDatabaseCentricDataModelforAndroidApplicationsTheAndroidDatabaseClassesDatabaseDesignforAndroidApplicationsBasicStructureoftheSimpleVideoDbHelperClassUsingtheDatabaseAPI:MJAndroidAndroidandSocialNetworkingTheSourceFolder(src)LoadingandStartingtheApplicationDatabaseQueriesandReadingDatafromtheDatabaseModifyingtheDatabasePartIIIASkeletonApplicationforAndroidAFrameworkforaWellBehavedApplicationVisualizingLifeCyclesVisualizingtheActivityLifeCycleVisualizingtheFragmentLifeCycleTheActivityClassandWellBehavedApplicationsTheActivityLifeCycleandtheUserExperienceLifeCycleMethodsoftheApplicationClassAFlowingandIntuitiveUserExperienceAcrossActivitiesMultitaskinginaSmallScreenEnvironmentTasksandApplicationsSpecifyingLaunchandTaskBehaviorTableofContents|ixUsingContentProvidersUnderstandingContentProvidersImplementingaContentProviderBrowsingVideowithFinchDefiningaProviderPublicAPIDefiningtheCONTENTURICreatingtheColumnNamesDeclaringColumnSpecificationStringsWritingandIntegratingaContentProviderCommonContentProviderTasksFileManagementandBinaryDataAndroidMVCandContentObservationACompleteContentProvider:TheSimpleFinchVideoContentProviderCodeTheSimpleFinchVideoContentProviderClassandInstanceVariablesImplementingtheonCreateMethodImplementingthegetTypeMethodImplementingtheProviderAPIDeterminingHowOftentoNotifyObserversDeclaringYourContentProviderExploringContentProvidersDevelopingRESTfulAndroidApplicationsA“NetworkMVC”SummaryofBenefitsCodeExample:DynamicallyListingandCachingYouTubeVideoContentStructureoftheSourceCodefortheFinchYouTubeVideoExampleSteppingThroughtheSearchApplicationStep:OurUICollectsUserInputStep:OurControllerListensforEventsStep:TheControllerQueriestheContentProviderwithamanagedQueryontheContentProviderModelStep:ImplementingtheRESTfulRequestConstantsandInitializationCreatingtheDatabaseANetworkedQueryMethodinsertandResponseHandlersFileManagement:StoringThumbnailsx|TableofContentsPartIVAdvancedTopicsMultimediaAudioandVideoPlayingAudioandVideoAudioPlaybackVideoPlaybackRecordingAudioandVideoAudioRecordingVideoRecordingStoredMediaContentLocationandMappingLocationBasedServicesMappingTheGoogleMapsActivityTheMapViewandMapActivityWorkingwithMapViewsMapViewandMyLocationOverlayInitializationPausingandResumingaMapActivityControllingtheMapwithMenuButtonsControllingtheMapwiththeKeypadLocationWithoutMapsTheManifestandLayoutFilesConnectingtoaLocationProviderandGettingLocationUpdatesUpdatingtheEmulatedLocationSensors,NFC,Speech,Gestures,andAccessibilitySensorsPositionOtherSensorsNearFieldCommunication(NFC)ReadingaTagWritingtoaTagPPModeGestureInputAccessibilityCommunication,Identity,Sync,andSocialMediaAccountContactsAuthenticationandSynchronizationAuthenticationTableofContents|xiSynchronizationBluetoothTheBluetoothProtocolStackBluez:TheLinuxBluetoothImplementationUsingBluetoothinAndroidApplicationsTheAndroidNativeDevelopmentKit(NDK)NativeMethodsandJNICallsConventionsontheNativeMethodSideConventionsontheJavaSideTheAndroidNDKSettingUptheNDKEnvironmentCompilingwiththeNDKJNI,NDK,andSDK:ASampleAppAndroidProvidedNativeLibrariesBuildingYourOwnCustomLibraryModulesNativeActivitiesIndexxii|TableofContentsPrefaceThepurposeofthisbookistoenableyoutocreatewellengineeredAndroidapplicationsthatgobeyondthescopeofsmallexampleapplicationsThisbookisforpeoplecomingtoAndroidprogrammingfromavarietyofbackgroundsIfyouhavebeenprogrammingiPhoneorMacOSapplicationsinObjectiveC,youwillfindcoverageofAndroidtoolsandJavalanguagefeaturesrelevanttoAndroidprogrammingthatwillhelpyoubringyourknowledgeofmobileapplicationdevelopmenttoAndroidIfyouareanexperiencedJavacoder,youwillfindcoverageofAndroidapplicationarchitecturethatwillenableyoutouseyourJavaexpertiseinthisnewlyvibrantworldofclientJavaapplicationdevelopmentInshort,thisisabookforpeoplewithsomerelevantexperienceinobjectorientedlanguages,mobileapplications,RESTapplications,andsimilardisciplineswhowanttogofurtherthananintroductorybookoronlinetutorialswilltakethemHowThisBookIsOrganizedWewanttogetyouofftoafaststartThechaptersinthefirstpartofthisbookwillstepyouthroughusingtheSDKtoolssothatyoucanaccessexamplecodeinthisbookandintheSDK,evenasyouexpandyourknowledgeofSDKtools,Java,anddatabasedesignThetoolsandbasicscoveredinthefirstpartmightbefamiliarenoughtoyouthatyouwouldwanttoskiptoPartIIwherewebuildfoundationalknowledgefordevelopinglargerAndroidapplicationsThecentralpartofthisbookisanexampleofanapplicationthatuseswebservicestodeliverinformationtotheusersomethingmanyapplicationshaveattheircoreWepresentanapplicationarchitecture,andanovelapproachtousingAndroid’sframeworkclassesthatenablesyoutodothisparticularlyefficientlyYouwillbeabletousethisapplicationasaframeworkforcreatingyourownapplications,andasatoolforlearningaboutAndroidprogrammingInthefinalpartofthisbook,weexploreAndroidAPIsinspecificapplicationareas:multimedia,location,sensors,andcommunication,amongothers,inordertoequipyoutoprogramapplicationsinyourspecificareaofinterestxiiiBythetimeyoureachtheendofthisbook,wewantyoutohavegainedknowledgebeyondreferencematerialandawalkthroughofexamplesWewantyoutohaveapointofviewonhowtomakegreatAndroidapplicationsConventionsUsedinThisBookThefollowingtypographicalconventionsareusedinthisbook:ItalicIndicatesnewterms,URLs,emailaddresses,filenames,andfileextensionsConstantwidthUsedforprogramlistings,aswellaswithinparagraphstorefertoprogramelementssuchasvariableorfunctionnames,databases,datatypes,environmentvariables,statements,andkeywordsConstantwidthboldShowscommandsorothertextthatshouldbetypedliterallybytheuserConstantwidthitalicShowstextthatshouldbereplacedwithusersuppliedvaluesorbyvaluesdeterminedbycontextThisiconsignifiesatip,suggestion,orgeneralnoteThisiconindicatesawarningorcautionUsingCodeExamplesThisbookisheretohelpyougetyourjobdoneIngeneral,youmayusethecodeinthisbookinyourprogramsanddocumentationYoudonotneedtocontactusforpermissionunlessyou’rereproducingasignificantportionofthecodeForexample,writingaprogramthatusesseveralchunksofcodefromthisbookdoesnotrequirepermissionSellingordistributingaCDROMofexamplesfromO’ReillybooksdoesrequirepermissionAnsweringaquestionbycitingthisbookandquotingexamplecodedoesnotrequirepermissionIncorporatingasignificantamountofexamplecodefromthisbookintoyourproduct’sdocumentationdoesrequirepermissionWeappreciate,butdonotrequire,attributionAnattributionusuallyincludesthetitle,author,publisher,andISBNForexample:“ProgrammingAndroidbyZigurdxiv|PrefaceMednieks,LairdDornin,GBlakeMeike,andMasumiNakamuraCopyrightO’ReillyMedia,Inc,”Ifyoufeelyouruseofcodeexamplesfallsoutsidefairuseorthepermissiongivenhere,feelfreetocontactusatpermissionsoreillycomSafariBooksOnlineSafariBooksOnlineisanondemanddigitallibrarythatletsyoueasilysearchmorethan,technologyandcreativereferencebooksandvideostofindtheanswersyouneedquicklyWithasubscription,youcanreadanypageandwatchanyvideofromourlibraryonlineReadbooksonyourcellphoneandmobiledevicesAccessnewtitlesbeforetheyareavailableforprint,andgetexclusiveaccesstomanuscriptsindevelopmentandpostfeedbackfortheauthorsCopyandpastecodesamples,organizeyourfavorites,downloadchapters,bookmarkkeysections,createnotes,printoutpages,andbenefitfromtonsofothertimesavingfeaturesO’ReillyMediahasuploadedthisbooktotheSafariBooksOnlineserviceTohavefulldigitalaccesstothisbookandothersonsimilartopicsfromO’Reillyandotherpublishers,signupforfreeathttp:mysafaribooksonlinecomHowtoContactUsPleaseaddresscommentsandquestionsconcerningthisbooktothepublisher:O’ReillyMedia,IncGravensteinHighwayNorthSebastopol,CA(intheUnitedStatesorCanada)(internationalorlocal)(fax)Wehaveawebpageforthisbook,wherewelisterrata,examples,andanyadditionalinformationYoucanaccessthispageat:http:oreillycomcatalogTocommentorasktechnicalquestionsaboutthisbook,sendemailto:bookquestionsoreillycomFormoreinformationaboutourbooks,courses,conferences,andnews,seeourwebsiteathttp:wwworeillycomFindusonFacebook:http:facebookcomoreillyFollowusonTwitter:http:twittercomoreillymediaPreface|xvWatchusonYouTube:http:wwwyoutubecomoreillymediaAcknowledgmentsTheauthorshaveadaptedportionsofthisbookfromtheirpreviouslyreleasedtitle,AndroidApplicationDevelopment(O’Reilly)DraftsofthisbookwerereleasedontheO’ReillyOpenFeedbackPublishingSystem(OFPS)inordertogetyourfeedbackonwhetherandhowwearemeetingthegoalsforthisbookWeareverygratefulforthereaderswhoparticipatedinOFPS,andweowethemmuchincorrectingourerrorsandimprovingourwritingOpenreviewofdraftswillbepartoffutureeditions,andwewelcomeyourviewsoneveryaspectofthisbookxvi|PrefacePARTIToolsandBasicsPartIshowsyouhowtoinstallanduseyourtools,whatyouneedtoknowaboutJavatowritegoodAndroidcode,andhowtodesignanduseSQLdatabases,whicharecentraltotheAndroidapplicationmodel,persistencesystem,andimplementationofkeydesignpatternsinAndroidprogramsCHAPTERYourToolkitThischaptershowsyouhowtoinstalltheAndroidsoftwaredevelopmentkit(SDK)andall

精彩专题

热门资料

maven权威指南.pdf

Git+使用教程.pdf

ASP毕业论文中英文资料外文翻译文献.doc

2010春季大赛题.doc

该用户的其他资料

  • 名称/格式
  • 评分
  • 下载次数
  • 资料大小
  • 上传时间

用户评论

0/200
    暂无评论
上传我的资料

相关资料换一换

资料评价:

/ 502
所需积分:1 立即下载
返回
顶部
举报
资料
关闭

温馨提示

感谢您对爱问共享资料的支持,精彩活动将尽快为您呈现,敬请期待!