关闭

关闭

封号提示

内容

首页 Programming Android.pdf

Programming Android.pdf

Programming Android.pdf

上传者: 陆永 2011-10-13 评分1 评论0 下载54 收藏0 阅读量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

职业精品

废旧物资处置管理办法.docx

学校固定资产管理制度.doc

机械合同范本.doc

显示屏广告发布合同范本.doc

用户评论

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

精彩专题

相关资料换一换

资料评价:

/ 502
所需积分:1 立即下载

意见
反馈

返回
顶部