2022年《移动应用开发》试题及答案.pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《2022年《移动应用开发》试题及答案.pdf》由会员分享,可在线阅读,更多相关《2022年《移动应用开发》试题及答案.pdf(23页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、移动应用开发试题及答案移动应用开发试题题目 : 1、请实现点击按钮拨打电话功能。(20 分)2、请实现点击按钮改变文本控件颜色的功能。(30 分)3、请实现使用socket 通信的服务器端代码。(50 分)要求 : 逻辑结构完整, 答案要点突出, 论述充分 , 每题答案字数不少于400 字。答案不得完全照抄书本或其她资料 , 不得互相抄袭。精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 1 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答案中南大学网络教育课程考试移动应用开发
2、答卷本人承诺 : 本试卷确为本人独立完成, 若有违反愿意接受处理。签名 :_学号 :_ 专业 :_ 学习中心 :_题号一二三总分评阅人签字成绩1.答: private Button btn2; btn2=(Button)findViewById(R、id 、btn2);/在 xml 中把 button2改成 btn2, 为该按钮的id btn2 、setOnClickListener(new OnClickListener(); 在 OnClick() Intent in2 = new Intent(); in2、setAction(Intent、ACTION_CALL);/ 指定意图动作 i
3、n2、setData(Uri、parse(tel:1836380000);/指定电话号码 startActivity(in2); 在 android系统中 , 所有系统请求 , 必须要在 androidmainfest、xml 中注册在application上面 MainActivity、java: package com 、example、qq; import android、net 、Uri; import android、os、Bundle; import android、app、Activity; import android、app、AlertDialog; import andro
4、id、app、Dialog; import android、content 、DialogInterface; import android、content 、Intent; import 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 Ma
5、inActivity extends Activity private Button btn; private Button btn2; private EditText et; private EditText et2; Override protected void onCreate(Bundle savedInstanceState) 精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 2 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答案 super、onCreate(s
6、avedInstanceState); 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)findViewById(R、id 、button1); btn、setOnClickListener(new OnClickListener() Override public
7、 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,SecActivity、 class); startActivity(in); else System、out 、 println(!); ); bt
8、n2、setOnClickListener(new OnClickListener() Override public void onClick(View arg0) / TODO Auto-generated method stub Intent in2 = new Intent(); in2 、setAction(Intent、ACTION_CALL); in2 、setData(Uri、parse(tel:); startActivity(in2); ); Override public boolean onCreateOptionsMenu(Menu menu) / Inflate t
9、he menu; this adds items to the action bar if it is present、 getMenuInflater()、inflate(R、menu 、main, menu); return true; androidmainfest、xml: 1.Android Layout文件Layout 文件, 用来呈现一个拨打电话的按钮。1. 2. 6.7.12.Activity使用以下代码 ,Android拨打电话 : 1. Intent callIntent = newIntent ( Intent 、ACTION_CALL);2.callIntent、set
10、Data ( Uri 、parse (tel:);3.startActivity( callIntent );文件:MainActivity、java 当点击拨打电话按钮时 , 就会拨打 这个号码。1. package net 、cublog 、android ;2. import android 、app、Activity;3. import android 、content 、Context ;4. import android 、content 、Intent ;5. import android 、net 、Uri ;6. import android 、os、Bundle;7. im
11、port android 、telephony 、PhoneStateListener;8. import android 、telephony 、TelephonyManager;9. import android 、util、Log;10.import android 、view、View;11.import android 、view、View、OnClickListener;12.import android 、widget 、Button ;13.publicclass MainActivity extendsActivity14.privateButtonbutton ;15.16
12、. Override17.publicvoid onCreate (Bundle savedInstanceState) 18.精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 5 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答案19.super、onCreate( savedInstanceState);20.setContentView ( R 、layout 、main);21.22.button = ( Button ) findViewById ( R 、id 、b
13、uttonCall);23.24./ add button listener25.button 、setOnClickListener(newOnClickListener()26.27. Override28.publicvoid onClick ( Viewarg0) 29.30.Intent callIntent = new Intent( Intent 、ACTION_CALL);31.callIntent、setData ( Uri 、parse (tel:);32.startActivity(callIntent);33.34.35.36.);37.38.39.40.41.Andr
14、oid Manifest拨打电话 ,Android需要 CALL_PHONE的权限。在 AndroidManifest、xml 中添加以下代码 : 精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 6 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答案1. 添加后 : 1. 2. 6.7.8.11.14.15.16.17.18.19.20.PhoneStateListener 例子精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 -
15、 - - - - - - - - -第 7 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答案更新上面的 Activity,模拟拨打电话的状态 , 当电话拨打结束后 , 返回原始 Activity,实际上只就是重启了这个activity。1. package net 、cublog 、android ;2. import android 、app、Activity;3. import android 、content 、Context ;4. import android 、content 、Intent ;5. import android 、net 、Uri
16、;6. import android 、os、Bundle;7. import android 、telephony 、PhoneStateListener;8. import android 、telephony 、TelephonyManager;9. import android 、util、Log;10.import android 、view、View;11.import android 、view、View、OnClickListener;12.import android 、widget 、Button ;13.publicclass MainActivity extendsAc
17、tivity14.privateButtonbutton ;15.16. Override17.publicvoid onCreate (Bundle savedInstanceState) 18.19.super、onCreate( savedInstanceState);20.setContentView ( R 、layout 、main);21.22.button = ( Button ) findViewById ( R 、id 、buttonCall);23.24./ add PhoneStateListener25.PhoneCallListener phoneListener
18、=new PhoneCallListener();26.TelephonyManager telephonyManager = ( TelephonyManager) this27.、getSystemService ( Context 、TELEPHONY_SERVICE);精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 8 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答案28.telephonyManager 、listen(phoneListener , PhoneS
19、tateListener、LISTEN_CALL_STATE);29.30.31./ add button listener32.button 、setOnClickListener(newOnClickListener()33.34. Override35.publicvoid onClick ( Viewarg0) 36.37.Intent callIntent = new Intent( Intent 、ACTION_CALL);38.callIntent、setData ( Uri 、parse (tel:);39.startActivity(callIntent);40.41.42.
20、43.);44.45.46.47./monitor phone call activities48.privateclass PhoneCallListener extendsPhoneStateListener 49.50.privateboolean isPhoneCalling =false ;51.52.String LOG_TAG = LOGGING 123 ;53.精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 9 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答
21、案54. Override55.publicvoidonCallStateChanged (intstate , StringincomingNumber)56.57.if( TelephonyManager、CALL_STATE_RINGING = state ) 58./ phone ringing59.Log、i ( LOG_TAG,RINGING, number: + incomingNumber);60.61.62.if( TelephonyManager、CALL_STATE_OFFHOOK = state ) 63./ active64.Log、i ( LOG_TAG,OFFHO
22、OK);65.66.isPhoneCalling =true ;67.68.69.if( TelephonyManager、CALL_STATE_IDLE = state ) 70./ run when class initial and phone call ended, 71./ need detect flag from CALL_STATE_OFFHOOK72.Log、i ( LOG_TAG,IDLE );73.74.if( isPhoneCalling) 75.精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - -
23、- - -第 10 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答案76.Log、i (LOG_TAG, restart app);77.78./ restart app79.Intent i = getBaseContext () 、getPackageManager()80.、getLaunchIntentForPackage(81.getBaseContext () 、getPackageName ();82.i 、addFlags( Intent 、FLAG_ACTIVITY_CLEAR_TOP);83.startActivity( i );84.85.
24、isPhoneCalling = false;86.87.88.89.90.91.由于 PhoneStateListener需要 READ_PHONE_STATE权限, 需要在 AndroidManifest、xml 中添加以下代码 : 1. 添加后 AndroidManifest、xml 如下: 1. 2. 6.7.8.9.12.15.16.17.18.19.20.21.1、答:MainActivity 、java import android、app、Activity; import android、content 、Intent; import android、net 、Uri; imp
25、ort android、os、Bundle; import android、view、Menu; 精品资料 - - - 欢迎下载 - - - - - - - - - - - 欢迎下载 名师归纳 - - - - - - - - - -第 12 页,共 23 页 - - - - - - - - - - 移动应用开发试题及答案import android、view、View; import android、view、View、OnClickListener; import android、widget 、Button; import android、widget 、TextView; public
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 移动应用开发 2022 移动 应用 开发 试题 答案
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内