【正文】
寫日期: 2012年 月 日 貴陽學(xué)院畢業(yè)設(shè)計(論文)摘 要當(dāng)今社會的生活節(jié)奏越來越快,隨著硬件移動設(shè)備的越來越先進,人們對移動設(shè)備的要求也越來越高,從以前的追求技術(shù)到現(xiàn)在的追求視覺效果及用戶體驗,因此,也逐步的提高了對系統(tǒng)的要求。同時給出了詳細的系統(tǒng)設(shè)計過程、部分界面截圖及主要的功能流程圖,本文還對開發(fā)過程中遇到的問題和解決方法進行了詳細的討論,該音樂播放器集下載、播放、暫停、停止等功能于一體,性能良好,在Android系統(tǒng)中能獨立運行。s increasingly fast pace of life in society, with the hardware of mobile devices bee increasingly sophisticated, people demand more and more mobile devices, high technology from the past to the present pursuit of the pursuit of visual and user experience, therefore, also gradually increased the system requirements. This article is in the Android system, music player application on the design and implementation to discuss the process through which to further study and application of Android, so the future development of personal sense. Music player of this paper uses Android opensource system technology, the use of Java language and Eclipse development tools for the preparation of the player code. At the same time gives a detailed system design process, some interface screenshots and the major function of flow, the paper also encountered in the process of development problems and solutions were discussed in detail, the music player, set download,play, pause, stop and other functions, good performance, in the Android system can run independently. MP3 is a pressed audio file format, as the player is limited to the application layer of the program, so not to go into the specific pression algorithm. Experiments show that, based on the Android platform, software development is simple, concise and easy to use, will bee the development direction of the next few years, have universal significance. Keywords: Android, music player, MP3 目 錄摘 要 IAbstract II第一章 引 言 1 項目背景 1 編寫目的 1第二章 Android應(yīng)用軟件開發(fā)基礎(chǔ) 3 Android簡介 3 Android應(yīng)用軟件開發(fā)的核心技術(shù) 4 Android 應(yīng)用開發(fā)語言 4 Android應(yīng)用程序組件 4 Intent 介紹 6 文件 6第三章 搭建Android開發(fā)環(huán)境 8 計算機配置 8 安裝JDK 8 安裝Eclipse 8 安裝SDK 9 安裝ADT 9 設(shè)置Eclipse 9 創(chuàng)建AVD 10第四章 系統(tǒng)需求分析 11 11 11 12 13 13 14第五章 音樂播放器詳細設(shè)計與實現(xiàn) 15 15 17 19 21第六章 結(jié) 論 24致 謝 25參考文獻 26附 錄 2733第一章 引 言 項目背景自2007年Google公司推出Android以來,一直受到人們的熱捧。這使得越來越多的人關(guān)注這個操作系統(tǒng)。要研究了各種市場上流行的手機播放器,了解它們各自的插件及編碼方式,還有各種播放器播放的特別文件格式,分析各種編碼方式的優(yōu)缺點,以及各種播放器本身的缺點和特點,編寫出功能實用,使用方便快捷的播放器。第二章 Android應(yīng)用軟件開發(fā)基礎(chǔ) Android簡介Android是一種以Linux為基礎(chǔ)的開放源碼操作系統(tǒng),主要使用于便攜設(shè)備。Android平臺五大優(yōu)勢特色:開放性掙脫運營商的束縛豐富的硬件選擇不受任何限制的開發(fā)商無縫結(jié)合的Google應(yīng)用 圖21 Android 軟件體系結(jié)構(gòu)圖Android作為一個移動設(shè)備的平臺,其軟件層次結(jié)構(gòu)包括了一個操作系統(tǒng)(OS),中間件(MiddleWare)和應(yīng)用程序(Application)。 Android應(yīng)用程序組件Android應(yīng)用程序最大的一個特點就是每個應(yīng)用都由若干組件構(gòu)成。也就是說,不同于我們平常編寫的程序,Android的應(yīng)用程序不是單一入口,而是可以從代碼的不同位置啟動。一個應(yīng)用程序也可能有不止一個activity。2. Serviceservice是一種沒有界面的組件,同我們平常在Windows或Linux系統(tǒng)中所理解的“服務(wù)”一樣,Android上的service也是運行在后臺的,運行時間可以從系統(tǒng)啟動到系統(tǒng)關(guān)閉為止。 Android允許activity連接到或者綁定到service上,這樣就可以讓用戶在界面上控制后臺service的行為。NitificationManager的通知形式有許多種,比如說振動、響鈴、閃LED燈,還可以在Android界面的消息欄處顯示信息。其它應(yīng)用程序在需要使用這些數(shù)據(jù)時,可以用ContentResolver對象,使用其中的方法。一般的應(yīng)用是通過Intent向Android系統(tǒng)發(fā)出某種請求,然后Android系統(tǒng)會根據(jù)請求查詢各個組件聲明的IntentFilter,找到需要的組件并運行它。我們通過manifest描述程序的信息,Android系統(tǒng)就能讀取出來并產(chǎn)生相應(yīng)的行為。 安裝JDK由于Android開發(fā)是基于Java的基礎(chǔ)上的,所以我們必須得安裝JDK(JDK下載地址:)。%JAVA_HOME%\bin?!?配置完成后,重啟可以在cmd下輸入java或者javac測試。(SDK下載地址:) 安裝ADT,就可以開始開發(fā)Android應(yīng)用程序了,但是為了更高效地進行開發(fā),Android團隊推出了Android Development Tools (ADT) 。3. 在彈出的Add Site 對話框中,任意填寫一個名字到Name一欄。5. 安裝完畢后將彈出窗口顯示ADT相關(guān)的各種信息以及許可協(xié)議,點擊“Finish“即可完成安裝。4. 點擊Apply,OK,設(shè)置生效。2. 點擊Opens the Android Virtual Device Manager圖標(biāo)按鈕。6. 在SD Card下的Size一欄填上我們要設(shè)定的SD卡容量大小。圖42 音樂播放器的時序圖從以上時序圖可以看到播放器中消息發(fā)送及調(diào)用過程。要考慮到不同手機屏幕大小可能不一樣,應(yīng)盡量兼容大多數(shù)手機屏幕尺寸,使之顯示無障礙。圖52 LocalActivity在LocalActivity中點擊列表中的歌曲名就會調(diào)出PlayerActivity(圖53),這個Activity就是播放音樂時的界面,其中有一些對播放器進行控制的控件。 String line = null。 // 使用io讀取數(shù)據(jù) buffer = new BufferedReader(new InputStreamReader( ()))。 } catch (Exception e2) { ()。在我所設(shè)計的播放器中所用到是實現(xiàn)SAX(Simple API for XML)接口的方式來解析XML文件,解析的實現(xiàn)代碼如下: //開始解析XML文件中的每一個標(biāo)簽時調(diào)用的方法 Override public void startElement(String uri, String localName, String qName, Attributes attr) throws SAXException { //將從XML文件中讀取到的標(biāo)簽名賦值給tagName tagName = localName。 } //讀取XML文件中沒一個標(biāo)簽中內(nèi)容 Override public void characters(char[] ch, int start, int length) throws SAXException { //將讀取到的內(nèi)容賦值給temp String temp = new String(ch, start, length)。 } else if (()) { (temp)。 // 啟動新線程 Thread thread = new Thread(downloadThread)。 public DownloadThread(Mp3Info mp3Info) { = mp3Info。 String resultMessage = null。 } else if (result == 1) { resultMessage = 文件已存在。 (resultMessage)。 return path。 mp3Info = (Mp3Info) (mp3Info)。 textView = (TextView) findViewById()。 (new StopButtonListener())。 ()。 isPause = true。 ()。第六章 結(jié) 論1. 通過對Android手機平臺的音樂播放器的開發(fā),使我對Android系統(tǒng)從零進入到了一個比較高的層次的了解,Android功能是如此強大,令人不得不佩服。4. 在進行聯(lián)網(wǎng)下載歌曲信息的時候總是失敗,再三確認代碼后,確定無誤,可還是下載失敗,后來經(jīng)老師指導(dǎo),才發(fā)現(xiàn),原來Android中的軟件聯(lián)網(wǎng)是需要權(quán)限的,同時我還順便了解到了,讀寫SDCard也是需要權(quán)限的。這里有治學(xué)嚴謹而又親切的老師,有互相幫助的同學(xué),更有積極、向上、融洽的學(xué)習(xí)生活氛圍。首先感謝指導(dǎo)老師。此外,他們的嚴謹治學(xué)態(tài)度和忘我的工作精神值得我去學(xué)習(xí)。同時,感謝四年來傳授我知識的老師們,更要感謝我的家人及朋友對我學(xué)業(yè)上的支持和鼓勵,感謝所有關(guān)心、幫助過我的人。參考文獻[1] 韓超,梁泉 著,Android系統(tǒng)原理及開發(fā)要點詳解,[2] 李寧,Android/OPhone 開發(fā)完全講義,中國水利水電出版社,[3] (美)埃克爾 著 陳昊鵬 譯,Java編程思想(第4版),機械工業(yè)出版社, [4] E2EColud工作室,深入淺出GoogleAndroid,人民郵電出版社,[5] 余志龍,王世江 改編,GoogleAndroidSDK開發(fā)范例大全,人民郵電出版社,[6] 毛應(yīng)爽,趙慧玲,孟憲穎,sql server 2005數(shù)據(jù)庫程序設(shè)計,清華大學(xué)出版社,[7] 龍馬工作室,新編Photoshop CS4中文版從入門到精通,人民郵電出版社,[8] 孫衛(wèi)琴,Tomcat與Java Web開發(fā)技術(shù)詳解(第2版),電子工業(yè)出版社 附 錄主界面MainActivity布局文件代碼:TabHost xmlns:android= android:id=android:id/tabhost android:layout_width=fill_parent android:layout_height=fill_parent a