




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、移動應用開發試題題目:1.請實現點擊按鈕撥打電話功能。(20分)2.請實現點擊按鈕轉變文本控件顏色的功能。(30分)3.請實現使用socket通信的服務器端代碼。(50分)要求:規律結構完整,答案要點突出,論述充分,每題答案字數不少于400字。答案不得完全照抄書本或其他資料,不得相互抄襲。歡迎下載中南高校網絡教育課程考試移動應用開發答卷本人承諾:本試卷確為本人獨立完成,若有違反情愿接受處理。簽名:_學號:_專業:_學習中心:_題號一二三總分評閱人簽字成果1. 答: private Button btn2;btn2=(Button)findViewById(R.id.btn2);/在xml中把b
2、utton2改成btn2,為該按鈕的idbtn2.setOnClickListener(new OnClickListener();在OnClick() Intent in2 = new Intent(); in2.setAction(Intent.ACTION_CALL);/指定意圖動作 in2.setData(Uri.parse("tel:1836380000");/指定電話號碼 startActivity(in2);在android系統中,全部系統懇求,必需要在androidmainfest.xml中注冊 在<application上面<uses-perm
3、ission android:name="android.permission.CALL_PHONE"/>MainActivity.java:package com.example.qq;import .Uri;import android.os.Bundle;import android.app.Activity;import android.app.AlertDialog;import android.app.Dialog;import android.content.DialogInterface;import android.content.Intent;im
4、port android.view.LayoutInflater;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;public class MainActivity extends Activity private Button btn;private Button btn2; private EditText et; private Edit
5、Text et2; Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et = (EditText)findViewById(R.id.editText1); et2 = (EditText)findViewById(R.id.editText2); btn2 = (Button)findViewById(R.id.btn2); btn = (Button)findViewB
6、yId(R.id.button1); btn.setOnClickListener(new OnClickListener()Overridepublic void onClick(View arg0) / TODO Auto-generated method stub final String str = et.getText().toString().trim(); final String str2 = et2.getText().toString().trim();if (str.equals(str2)Intent in = new Intent(MainActivity.this,
7、SecActivity.class);startActivity(in);elseSystem.out.println("!");); btn2.setOnClickListener(new OnClickListener()Overridepublic void onClick(View arg0) / TODO Auto-generated method stubIntent in2 = new Intent();in2.setAction(Intent.ACTION_CALL);in2.setData(Uri.parse("telq
8、uot;);startActivity(in2);); Override public boolean onCreateOptionsMenu(Menu menu) / Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; androidmainfest.xml:<?xml version="1.0" encoding="utf-8"?>&l
9、t;manifest xmlns:android=" package="com.example.qq" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="17" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.CALL
10、_PHONE"/> <application android:allowBackup="true" android:icon="drawable/ic_launcher" android:label="string/app_name" android:theme="style/AppTheme" > <activity android:name="com.example.qq.MainActivity" android:label="string/ap
11、p_name" > <intent-filter> <action android:name="ent.action.MAIN" /> <category android:name="ent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.qq.SecActivity" android:
12、label="string/title_activity_sec" > </activity> </application></manifest>1. Android Layout文件Layout文件,用來呈現一個撥打電話的按鈕。1. <?xml version="1.0" encoding="utf-8"?>2. <LinearLayout xmlns:android="3. android:layout_width
13、="fill_parent"4. android:layout_height="fill_parent"5. android:orientation="vertical" >6.7. 8. <Button9. android:id="+id/
14、buttonCall"10. android:layout_width="wrap_content"11. android:layout_height="wrap_content"12. android:text="callq
15、uot; />13.14. </LinearLayout>Activity使用以下代碼,Android撥打電話:1. Intent callIntent = new Intent(Intent.ACTION_CALL);2. callIntent.setData(Uri.parse("telquot;);3.
16、60; startActivity(callIntent);文件:MainActivity.java 當點擊撥打電話按鈕時,就會撥個號碼。1. package net.cublog.android;2.3. import android.app.Activity;4. import android.content.Context;5. import android.content.Intent;6. import .Uri;7.
17、 import android.os.Bundle;8. import android.telephony.PhoneStateListener;9. import android.telephony.TelephonyManager;10. import android.util.Log;11. import android.view.View;12. import android.view.View.OnClickListener;13. import android.widget.Button;14.15. public class MainActivity extends Activi
18、ty 16. private Button button;17. 18. Override19. public void onCreate(Bundle savedInstanceState) 20. 21. super.onCreate(savedInstanceState);22.
19、; setContentView(R.layout.main);23. 24. button = (Button) findViewById(R.id.buttonCall);25. 26. / add button
20、listener27. button.setOnClickListener(new OnClickListener() 28. 29. Override30. public void onClick(Vi
21、ew arg0) 31. 32. Intent callIntent = new Intent(Intent.ACTION_CALL);33. callIntent.setData(Uri.parse(&
22、quot;telquot;);34. startActivity(callIntent);35. 36. 37. 38.
23、0;);39. 40. 41. 42. 43. Android Manifest撥打電話,Android需要CALL_PHONE的權限。在AndroidManifest.xml中添加以下代碼:1. <uses-permission android:name="android.permission.CALL_PHONE" />添加后:1. <?xml version="1.0" encoding="
24、;utf-8"?>2. <manifest xmlns:android="3. package="net.cublog.android"4. android:versionCode="1"5. android:versionName="1.0" >6.7. <uses-sdk android:minSd
25、kVersion="7" />8. <uses-permission android:name="android.permission.CALL_PHONE" />9.10. <application11. android:icon="drawable/ic_launcher"12. &
26、#160; android:label="string/app_name" >13. <activity14. android:name=".MainActivity"15. &
27、#160; android:label="string/app_name" >16. <intent-filter>17. <action android:name=&quo
28、t;ent.action.MAIN" />18.19. <category android:name="ent.category.LAUNCHER" />20. </
29、intent-filter>21. </activity>22. </application>23.24. </manifest>PhoneStateListener 例子更新上面的Activity,模擬撥打電話的狀態,當電話撥打結束后,返回原始Activity,實際上只是重啟了這個activity。1. package net.cublog.android;2.3. import android.app.Ac
30、tivity;4. import android.content.Context;5. import android.content.Intent;6. import .Uri;7. import android.os.Bundle;8. import android.telephony.PhoneStateListener;9. import android.telephony.TelephonyManager;10. import android.util.Log;11. import android.view.View;12. import android.view.View.OnCli
31、ckListener;13. import android.widget.Button;14.15. public class MainActivity extends Activity 16. private Button button;17. 18. Override19. public void onCreate(Bundle savedInstanceState) 20. 21. &
32、#160; super.onCreate(savedInstanceState);22. setContentView(R.layout.main);23. 24. button = (Button) findViewById(R.id.buttonCall);25.
33、0; 26. / add PhoneStateListener27. PhoneCallListener phoneListener = new PhoneCallListener();28. TelephonyManager telephonyManager =
34、(TelephonyManager) this29. .getSystemService(Context.TELEPHONY_SERVICE);30. telephonyManager.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);31. 32.
35、160; 33. / add button listener34. button.setOnClickListener(new OnClickListener() 35. 36. Overrid
36、e37. public void onClick(View arg0) 38. 39. Intent callIntent = new Intent(Intent.ACTION_CALL);40.
37、60; callIntent.setData(Uri.parse("telquot;);41. startActivity(callIntent);42. 43.
38、60; 44. 45. );46. 47. 48. 49. /monitor phone call activities50. private class PhoneCallListener extends Phone
39、StateListener 51. 52. private boolean isPhoneCalling = false;53. 54. String LOG_TAG = "LOGGING 123"55. 56. Override57.
40、60; public void onCallStateChanged(int state, String incomingNumber) 58. 59. if (TelephonyManager.CALL_STATE_RINGING = state) 60.
41、60; / phone ringing61. Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);62. 63.
42、60;64. if (TelephonyManager.CALL_STATE_OFFHOOK = state) 65. / active66.
43、 Log.i(LOG_TAG, "OFFHOOK");67. 68. isPhoneCalling = true;69. 70. 71.
44、 if (TelephonyManager.CALL_STATE_IDLE = state) 72. / run when class initial and phone call ended, 73. &
45、#160; / need detect flag from CALL_STATE_OFFHOOK74. Log.i(LOG_TAG, "IDLE");75. 76.
46、0; if (isPhoneCalling) 77. 78. Log.i(LOG_TAG, "restart app");79. 80.
47、 / restart app81. Intent i = getBaseContext().getPackageManager()82.
48、0; .getLaunchIntentForPackage(83.
49、60;getBaseContext().getPackageName();84. i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);85.
50、160; startActivity(i);86. 87. isPhoneCalling = false;88.
51、0;89. 90. 91. 92. 93. 由于PhoneStateListener需要READ_PHONE_STATE權限,需要在AndroidManifest.xml中添加以下代碼:1. <uses-permission android:name="android.permiss
52、ion.READ_PHONE_STATE" />添加后AndroidManifest.xml如下:1. <?xml version="1.0" encoding="utf-8"?>2. <manifest xmlns:android="3. package="net.cublog.android"4. android:versionCode="1"5.
53、 android:versionName="1.0" >6.7. <uses-sdk android:minSdkVersion="7" />8. <uses-permission android:name="android.permission.CALL_PHONE" />9. <uses-permission android:nam
54、e="android.permission.READ_PHONE_STATE" />10.11. <application12. android:icon="drawable/ic_launcher"13. android:label="string/app_name" >14.
55、 <activity15. android:name=".MainActivity"16. android:label="string/app_name" >17.
56、 <intent-filter>18. <action android:name="ent.action.MAIN" />19.20.
57、160; <category android:name="ent.category.LAUNCHER" />21. </intent-filter>22. </activ
58、ity>23. </application>24.25. </manifest>1. 答:MainActivity.javaimport android.app.Activity;import android.content.Intent;import .Uri;import android.os.Bundle;import android.view.Menu;import android.view.View;import android.view.View.OnClickListener;import androi
59、d.widget.Button;import android.widget.TextView;public class MainActivity extends Activity private Button mCallButton;Overrideprotected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mCallButton = (Button) findViewById(R.id.btn_call)
60、;mCallButton.setOnClickListener(new OnClickListener() Overridepublic void onClick(View v) / TODO Auto-generated method stub/打給聯通客服10010Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:10010");startActivity(intent););/Override/public boolean onCreateOptionsMenu(Menu menu) / Infl
61、ate the menu; this adds items to the action bar if it is present./getMenuInflater().inflate(R.menu.main, menu);/return true;/public void clickHandler(View source)/TextView tv = (TextView) findViewById(R.id.show);/tv.setText("你好!現在時間:" + new java.util.Date();/activity_main.xml: <Relative
62、Layout xmlns:android=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="dimen/activity_vertical_margin" android:paddingLeft="dimen/activity_horizontal_margin" android:paddingRight="dim
63、en/activity_horizontal_margin" android:paddingTop="dimen/activity_vertical_margin" tools:context=".MainActivity" > <TextView android:id="+id/show" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alig
64、nParentLeft="true" android:layout_alignParentTop="true" android:text="string/hello_world" /> <Button android:id="+id/btn_click" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="id/sho
65、w" android:text="點擊我" android:onClick="clickHandler"/> <Button android:id="+id/btn_call" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="id/btn_click" android:text="撥打電話"/&
66、gt;</RelativeLayout>AndroidManifest.xml: <?xml version="1.0" encoding="utf-8"?><manifest xmlns:android=" package="com.xiami.caipiao" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8
67、" android:targetSdkVersion="18" /><uses-permission android:name="android.permission.CALL_PHONE"/> <application android:allowBackup="true" android:icon="drawable/ic_launcher" android:label="string/app_name" android:theme="style/A
68、ppTheme" > <activity android:name="com.xiami.caipiao.MainActivity" android:label="string/app_name" > <intent-filter> <action android:name="ent.action.MAIN" /> <category android:name="ent.category.LAUNCHER" /&g
69、t; </intent-filter> </activity> </application></manifest>2.答:打開表單模板:%FR_HOME%WebReportWEB-INFreportletsdemoanalyticsmulti_reportall.frm。選中總體概況按鈕,在右側的屬性表中添加點擊大事。具體的js代碼如下:if(window.oldtd != null) window.oldtd.removeAttr("style"); var td; if($(e.target).is("butto
70、n") td=$(e.target).parent().parent(); else td=$(e.target).find("button").parent().parent(); td.css("background-image":"url()","background-color":"rgb(170, 223, 248)"); window.oldtd=td; 3. 答:服務器端 author version1.002008/8/2 /
71、60;.ServerSocket; .Socket; importjava.io.IOException; importjava.io.BufferedReader; importjava.io.InputStreamReader; importjava.io.PrintWriter; publicclassServerSocketTest privateServerSocketss; privateSocketsocket; privateBufferedReaderin;
72、;privatePrintWriterout; publicServerSocketTest() try ss=newServerSocket(10000);/建立服務器,監聽. System.out.println("Serverislisteningat10000."); while(true) socket=ss.accept(); /獵取客戶端IP地址 StringremoteIP=socket.getInetAddress().getHostAddress();
73、60;/獵取客戶端連接端口 StringremotePort=":"+socket.getLocalPort(); System.out.println("Aclinetcomein!IP:"+remoteIP+remotePort); /讀取客戶端輸入 in=newBufferedReader(newInputStreamReader(socket.getInputStream(); Stringline=in.readLine(); System.out.println(&quo
74、t;Clientsendis:"+line); /將服務器端信息發往客戶端 out=newPrintWriter(socket.getOutputStream(),true); out.println("YourMessageReceived!"); out.close(); in.close(); socket.close(); catch(IOExceptionex) System.out.println(ex.getCause(); publicstaticvoidmain(Stringargs) newServerSock
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 生物●海南卷丨2024年海南省普通高中學業水平選擇性考試生物試卷及答案
- 統編版語文三下( 第三單元重難點梳理)復習課件
- 寧夏青銅峽市寧朔縣中2022-2023學年高二下學期期末考試化學試題(含答案)
- 汽車傳感器與檢測技術電子教案:輪速傳感器
- 售電公司客戶管理制度
- 白玉蘭小區方案86p
- 商貿公司門店管理制度
- 從化溪頭破冰活動方案
- 倉庫低價活動策劃方案
- 仙湖團建活動方案
- KAT1-2023井下探放水技術規范
- 卡薩帝小程序用戶運營優化思考方案
- GB/T 44733-2024國家森林鄉村評價指標
- 消防工程火災自動報警及聯動控制系統安裝施工方案
- 2024年中考語文試題分類匯編:字音字形
- 《剪映專業版:短視頻創作案例教程(全彩慕課版)》 課件 第2章 剪映專業版快速入門
- JJF 1375-2024 機動車發動機轉速測量儀校準規范
- 重力儲能經濟與環境效益評估
- 20S515 鋼筋混凝土及磚砌排水檢查井
- 智慧燈桿一鍵求助對講廣播解決方案
- 事業單位員工在職證明模板(9篇)
評論
0/150
提交評論