


下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、作業(yè)說(shuō)明:.做作業(yè)之前首先在封面填上自己的學(xué)號(hào)和姓名,做完作業(yè)后請(qǐng)寫(xiě)上作業(yè)完成時(shí)間。.學(xué)習(xí)完第4-6單元之后必須完本錢(qián)次作業(yè),并請(qǐng)?jiān)谝?guī)定時(shí)間內(nèi)通過(guò)學(xué)習(xí)平臺(tái)提交Word文檔形式的電子作業(yè),本次作業(yè)占形成性考核總成績(jī)的20%o作業(yè)內(nèi)容:請(qǐng)將學(xué)習(xí)單元4、5、6中實(shí)驗(yàn)局部的工程中程序文件(.java文件,不包括資源文 件.xml)源碼貼在以下位置,格式為先寫(xiě)文件名后貼代碼,如下:1 MainActivity.javapackage import單元4on Attach?;卣{(diào)方法Public static class FragmentA extends ListFragmentOnArticlesSel
2、ectedListener listener; OverridePublic void onAttach(Context context)super.onAttach(context);tryListener=(OnArticlesSelectedListener)context; catch(ClassCastException e)thrownew ClassCastExceptiocontext.toStringO+must implementOnArticleSelectedListener,r);) )通過(guò)調(diào)用onArticleSelected。與Activity共享事件: publ
3、ic static class FragmentA extends ListFragmentOnArticleSelectedListener listener; Overridepublic void onListItemClick(ListView l,View v, int position,long id)/Append the clicked items row ID with the content provider UriUri noteUri=ContentUris.withAppendedId(ArticleColumns.CONTENT_URI,id);/Send the
4、event and Uri to the host activity Listener.onArticleSelected(noteUri);) )單元5廣播接收器記錄并顯示廣播內(nèi)容public class MyBroadcastReceiver extends BroadcastReceiverprivate static final String TAG=MyBroadcastReceiver;Overridepublic void onReceive(Context context,Intent intent)StringBuilder sb=new StringBuilder();sb
5、.append(Action:+intent.getAction()+n);sb.append(URI:+iment.toUri(Inten.URINTENT_SCHEME).toString()+n);String log=sb.toString();Log.d(TAQlog);Toast.makeText(context,log,Toast.LENGTH_LONG).show();)適用于后臺(tái)線程public class MyBroadcastReceiver extends BroadcastReceiverprivate static final String TAG=MyBroadc
6、astReceiver;Overridepublic void onReceive(Context context,Intent intent) final PendingResult pendingResult=goAsync();Task asyncTask=new Task(pendingResult,intent);asyncTask.execute();)Private static class Task extends AsyncTaskprivate final PendingResult pendingResult;private final Intent intent;pri
7、vate Task(PendingResult pendingResult,Intent intent) this.pendingResult=pendingResulfthis, intent二intent;)OverrideProtected String doInBackground(String. strings)(StringBuilder sb=new StringBuilder();sb.append(Action:+intent.getAction()+rr);sb.append(URI:+intent.toUri(Intent.URINTENT_SCHEME).toStrin
8、g()+“ir);String log=sb.toString();Log.d(TAQlog);return log;)Overrideprotected void onPostExecute(String s)super.onPostExecute(s);/Must call finish()so the BroadcastReceiver can be recycled.pendingResult.finish();單元6在Activity中定義一個(gè)ServiceConnection類(lèi)和DownloadBinder對(duì)象,并初始化代碼:private ServiceConnection mS
9、erviceConnection;private DownloadBinder mDownloadBinder;mServiceConnection-new ServiceConnectionOlpublic voidpublic voidonServiceConnected(ComponentNamename,IBinder service)1mDownloadBinder (DownloadBinder)service;實(shí)現(xiàn) Button3、Button4 Button5 Button6 點(diǎn)擊事件代碼Button3:Intent bindintent-new Intent(this,MyService class);bindService(bindIntent,mServiceConnec
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 豫章師范學(xué)院《油畫(huà)靜物技法與表現(xiàn)》2023-2024學(xué)年第二學(xué)期期末試卷
- 珠海格力職業(yè)學(xué)院《藏文文法上》2023-2024學(xué)年第二學(xué)期期末試卷
- 遼寧石化職業(yè)技術(shù)學(xué)院《語(yǔ)文學(xué)科教育論》2023-2024學(xué)年第二學(xué)期期末試卷
- 西安歐亞學(xué)院《數(shù)據(jù)分析與可視化》2023-2024學(xué)年第二學(xué)期期末試卷
- 南京工業(yè)大學(xué)《建筑防火設(shè)計(jì)》2023-2024學(xué)年第二學(xué)期期末試卷
- 西安科技大學(xué)高新學(xué)院《汽車(chē)發(fā)展史》2023-2024學(xué)年第二學(xué)期期末試卷
- 遼寧工程技術(shù)大學(xué)《資產(chǎn)評(píng)估學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 四川航天職業(yè)技術(shù)學(xué)院《嵌入式系統(tǒng)設(shè)計(jì)與開(kāi)發(fā)》2023-2024學(xué)年第二學(xué)期期末試卷
- 合肥信息技術(shù)職業(yè)學(xué)院《建筑類(lèi)專(zhuān)業(yè)導(dǎo)論》2023-2024學(xué)年第二學(xué)期期末試卷
- 南華大學(xué)船山學(xué)院《素描半身帶手及全身像實(shí)踐教學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- ESAP法律英語(yǔ)教程全冊(cè)配套優(yōu)質(zhì)教學(xué)課件
- 水資源保護(hù)知識(shí)競(jìng)賽試題及答案
- 道路清掃保潔-組織機(jī)構(gòu)框架圖、內(nèi)部分工
- PCB制程漲縮系數(shù)操作指引
- 標(biāo)準(zhǔn) DB37T 3690.1-2019 液體菌種制備技術(shù)規(guī)程 第1部分:香菇規(guī)范
- 2021五年級(jí)道德與法治培優(yōu)輔差計(jì)劃3篇
- 靜脈藥物配置中心課件
- 最新2022年減肥食品市場(chǎng)現(xiàn)狀與發(fā)展趨勢(shì)預(yù)測(cè)
- 發(fā)展?jié)h語(yǔ)初級(jí)綜合1:第30課PPT課件[通用]
- 馬工程西方經(jīng)濟(jì)學(xué)(第二版)教學(xué)課件-(4)
- 醫(yī)療廢物管理組織機(jī)構(gòu)架構(gòu)圖
評(píng)論
0/150
提交評(píng)論