关键词不能为空

当前您在: 主页 > 英语 >

《移动应用开发》试题及答案

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-06 02:11
tags:

-

2021年2月6日发(作者:手机词典)


《移动应用开发》试题




题目:



1.


请实现点击按钮拨打电话功能。



20


分)



2.


请实现点击按钮改变文本控 件颜色的功能。



30


分)

< p>


3.


请实现使用


soc ket


通信的服务器端代码。



50< /p>


分)



要求:逻辑结构完整,答案要点突 出,论述充分,每题答案字数不少于


400


字。答案不得完全照 抄书本


或其他资料,不得互相抄袭。






2016



12



(


专 科


)


中南大学网络教育课程考试



《移动应用开发


》答卷



本人承诺:本试卷确为本人独立完成,若有违反愿意接受处理。


签名



______________


< p>
学号:


____________________


专业:


__________________


学习中心:< /p>


_________________




题号



成绩



答:




private Button btn2;



btn2=(Button)findViewById(2);//



xml


中把


bu tton2


改成


btn2


,为该按钮的


id



lickListener(new OnClickListener(){});


④在


OnClick()


Intent in2 = new Intent();


ion(_CALL);//


指定意图动作



a((


指定电话号码



startActivity(in2);


⑤在


android


系统中,所有系统请求,必须要在


中注册





上面




:



package



import ;


import


import ty;


import ialog;


import


import Interface;


import


import Inflater;


import


import


import kListener;


import


import xt;



public class MainActivity extends Activity {




private Button btn;


移动应用开发




1





24













总分




评阅人签字




1.



/a191030148/article/details/9396099


2016



12


月< /p>


(


专科


)



private Button btn2;


private EditText et;


private EditText et2;


@Override


protected void onCreate(Bundle savedInstanceState) {


te(savedInstanceState);


setContentView(ty_main);




et = (EditText)findViewById(xt1);




et2 = (EditText)findViewById(xt2);



btn2 = (Button)findViewById(2);


btn = (Button)findViewById(1);


lickListener(new OnClickListener(){











































@Override


public void onClick(View arg0) {







// TODO Auto-generated method stub


Intent in2 = new Intent();


ion(_CALL);


a((


startActivity(in2);
































@Override


public void onClick(View arg0) {



// TODO Auto-generated method stub


final String str = t().toString().trim();


final String str2 = t().toString().trim();











if ((str2))


{




}


else


{



}


n(


Intent in = new Intent(,);


startActivity(in);


}});


lickListener(new OnClickListener(){


}});


移动应用开发




2





24




2016



12



(


专科


)


}




@Override


public boolean onCreateOptionsMenu(Menu menu) {


// Inflate the menu; this adds items to the action bar if it is present.


getMenuInflater().inflate(, menu);


return true;


}



}



:





package=


android:versionCode=


android:versionName=




android:minSdkVersion=


android:targetSdkVersion=





android:allowBackup=


android:icon=


android:label=


android:theme=



android:name=


android:label=









android:name=


android:label=




移动应用开发




3





24




2016



12



(


专科


)





1.



/




Android Layout


文件



Layout


文件,用来呈现一个拨打电话的按钮。



1.




xml


version


=




encoding


=



>



2.



<


LinearLayout


xml ns:android


=



androi d



3.







and roid:layout_width


=




4.







android:layout_ height


=




5.







android:orienta tion


=




>



6.




7.








8.






<


Button


9.











android:id

< p>
=




10.











android:layout_ width


=



nt


11.











and roid:layout_height


=


ent



12.











android:text


=




/>



13.




14.




LinearLayout


>




Activity



使用以下代码,


Android


拨打电话:

< p>


1.



Intent callIntent


=



new


Intent


(


Intent


.


ACTION_CALL

< p>
);



2.



















callIntent


.


setData< /p>


(


Uri


.


pa rse


(



));



3.



















startActivity


(


call


Intent

< br>);



移动应用开发




4





24




2016



12



(


专科


)


文件:



当点击拨打电话按钮时,就会 拨打



这个号码。




1.



package



net


.


cublog


.


andr oid


;



2.




3.



import


android


.


app


.


Activity


;



4.



import


android


.


content


.


Context


;



5.



import


android


.


content


.


Intent

< p>
;



6.



import


android


.


net


.


Uri


;



7.



import


android


.


os


.


Bundle


;



8.



import


android


.


telephony


.


PhoneStat eListener


;



9.



import


android


.


telephony


.


Telephony Manager


;



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



Activity



{



16.







private



Button



button


;



17.








18.







@


Override



19.







public



void


onCreate


(


Bundle


s avedInstanceState


)



{



20.





21.











super


.


onCreate

< p>
(


savedInstanceStat


e


);



22.











setContentView


(


R


.


layout


.


m ain


);



23.





24.











button



=



(


But ton


)



findViewById


(


R


.


id< /p>


.


buttonCall


);

< p>


25.












26.











// add button listener



27.











button


.


setOnClickLi stener


(


new



OnClickListener


()



{



28.





29.















@


Override



移动应用开发




5





24




2016



12



(


专科


)


30.















public



void


onClick


(


View



arg0


)



{



31.





32.



















Intent


callIntent


=



new


Intent


(


Intent


.


ACTION_CALL


);



33.



















callIntent

< p>
.


setDa


ta


(


Uri


.


parse


(



));



34.



















startActivity


(


ca


llIntent

< br>);



35.





36.















}



37.





38.











});



39.





40.







}



41.








42.






43.



}




Android Manifest



拨打电话,


Android


需要


CALL_PHONE


的权限。


< p>



中添加以下代码:



1.



<


us es


-


permission



android


:


name

< br>=




/>



添加后:



1.




xml


version


=




encoding


=



>



2.



<


manifest


xmlns:a ndroid


=



android



3.







pac kage


=




4.







android:version Code


=




5.







android:version Name


=




>



6.




移动应用开发




6





24




2016



12



(


专科


)


7.







<


uses-sdk android:minSdkVers ion


=




/>



8.







<


uses-permission


android:name


=




/>



9.




10.







<


application


11.











android:icon


=



her



12.











android:label


=




>



13.











<


activity


14.















android:name


=



ity



15.















android:label


=



pp_name



>



16.















<


intent- filter


>



17.



















<


action


android:n ame


=




/>



18.




19.



















<


category


android :name


=




/>



20.
















intent- filter


>



21.












ac tivity


>



22.








ap plication


>



23.




24.




manifest


>






PhoneStateListener


例子



更新上面的

Activity


,模拟拨打电话的状态,当电话拨打结束后,返回原始

< p>
Activity


,实际


上只是重启了这个


activity




1.



package



net


.


cublog


.


andr oid


;



2.




3.



import


android


.


app


.


Activity


;



4.



import


android


.


content


.


Context


;



移动应用开发




7





24




2016



12



(


专科


)


5.



import


android


.


content


.


Intent

< p>
;



6.



import


android


.


net


.


Uri


;



7.



import


android


.


os


.


Bundle


;



8.



import


android


.


telephony


.


PhoneStat eListener


;



9.



import


android


.


telephony


.


Telephony Manager


;



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



Activity



{



16.







private



Button



button


;



17.








18.







@


Override



19.







public



void


onCreate


(


Bundle


s avedInstanceState


)



{



20.





21.











super


.


onCreate

< p>
(


savedInstanceStat


e


);



22.











setContentView


(


R


.


layout


.


m ain


);



23.





24.











button



=



(


But ton


)



findViewById


(


R


.


id< /p>


.


buttonCall


);

< p>


25.












26.











// add PhoneStateListener



27.











PhoneCallListener


phoneListener


=



new


PhoneCallListener


();



28.











TelephonyManager


telephonyManager


=



(


Tel ephonyManager


)



this



29.















.


get SystemService


(


Contex

< br>t


.


TELEPHONY_SERVICE


);



30.











telephonyManager


.


li sten


(


phoneLis


tene r


,


PhoneStateListener

< br>.


LISTEN_CALL_STATE


);

< p>


31.





32.












移动应用开发




8





24




2016



12



(


专科


)


33.











// add button listener



34.











button


.


setOnClickLi stener


(


new



OnClickListener


()



{



35.





36.















@


Override



37.















public



void


onClick


(


View



arg0


)



{



38.





39.



















Intent


callIntent


=



new


Intent


(


Intent


.


ACTION_CALL


);



40.



















callIntent

< p>
.


setDa


ta


(


Uri


.


parse


(



));



41.



















startActivity


(


ca


llIntent

< br>);



42.





43.















}



44.





45.











});



46.





47.







}



48.








49.







//monitor phone call activities



50.







private



class


PhoneCallListener


extends



PhoneStateListener


{



51.





52.











private



boolean


isPhoneCalling


=



false


;



53.





54.











String


LOG_TAG


=




;



55.





56.











@


Override



57.











public



void



onCallStateC hanged


(


int



state


,



String



incomingNumber


)



{



58.





移动应用开发




9





24




2016



12



(


专科


)


59.















if


< /p>


(


TelephonyManager


.


CALL_STATE_RINGING


==



state


)



{



60.



















// phone ringing



61.



















Log


.


i


(


LOG_TAG

< br>,





+


incomingNumber


);



62.















}



63.





64.















if


< /p>


(


TelephonyManager


.


CALL_STATE_OFFHOOK


==



state


)



{



65.



















// active



66.



















Log


.


i


(


LOG_TAG

< br>,




);



67.





68.



















isPhoneCalling


=



true


;



69.















}



70.





71.















if


< /p>


(


TelephonyManager


.


CALL_STATE_IDLE


==



state


)



{



72.



















//


run


when


class


initial and phone call ended,



73.



















// need detect


flag from CALL_STATE_OFFHOOK



74.



















Log


.


i


(


LOG_TAG

< br>,




);



75.





76.



















if


< /p>


(


isPhoneCalling


)



{



77.





78.























Log


.


i


(


LO


G_ TAG


,




);



79.





80.























//


restart app



移动应用开发




10





24




2016



12



(


专科


)


81.























Intent i


=


getBaseContext


( ).


getPackageManager


()



82.



























.


getLaunchIntentForPackage


(



83.































get BaseContext


().


getPackageName


());



84.























i


.


addFla


gs


(


Intent


.


FLAG_ACTIVITY_CLEAR_ TOP


);



85.























startAct


ivity


(


i


);



86.





87.























isPhoneC


alling


=


false


;



88.



















}



89.





90.















}



91.











}



92.







}



93.



}



由于


PhoneStateListener

< br>需要


READ_PHONE_STATE


权限,需要在< /p>



中添


加以下代码:



1.



<


uses-permission


android:name


=




/>



添加后



如下:



1.




xml


version


=




encoding


=



>



2.



<


manifest


xmlns:a ndroid


=



android



3.







pac kage


=




4.







android:version Code


=




5.







android:version Name


=




>



移动应用开发




11





24



-


-


-


-


-


-


-


-



本文更新与2021-02-06 02:11,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/604787.html

《移动应用开发》试题及答案的相关文章

  • 余华爱情经典语录,余华爱情句子

    余华的经典语录——余华《第七天》40、我不怕死,一点都不怕,只怕再也不能看见你——余华《第七天》4可是我再也没遇到一个像福贵这样令我难忘的人了,对自己的经历如此清楚,

    语文
  • 心情低落的图片压抑,心情低落的图片发朋友圈

    心情压抑的图片(心太累没人理解的说说带图片)1、有时候很想找个人倾诉一下,却又不知从何说起,最终是什么也不说,只想快点睡过去,告诉自己,明天就好了。有时候,突然会觉得

    语文
  • 经典古训100句图片大全,古训名言警句

    古代经典励志名言100句译:好的药物味苦但对治病有利;忠言劝诫的话听起来不顺耳却对人的行为有利。3良言一句三冬暖,恶语伤人六月寒。喷泉的高度不会超过它的源头;一个人的事

    语文
  • 关于青春奋斗的名人名言鲁迅,关于青年奋斗的名言鲁迅

    鲁迅名言名句大全励志1、世上本没有路,走的人多了自然便成了路。下面是我整理的鲁迅先生的名言名句大全,希望对你有所帮助!当生存时,还是将遭践踏,将遭删刈,直至于死亡而

    语文
  • 三国群英单机版手游礼包码,三国群英手机单机版攻略

    三国群英传7五神兽洞有什么用那是多一个武将技能。青龙飞升召唤出东方的守护兽,神兽之一的青龙。玄武怒流召唤出北方的守护兽,神兽之一的玄武。白虎傲啸召唤出西方的守护兽,

    语文
  • 不收费的情感挽回专家电话,情感挽回免费咨询

    免费的情感挽回机构(揭秘情感挽回机构骗局)1、牛牛(化名)向上海市公安局金山分局报案,称自己为了挽回与女友的感情,被一家名为“实花教育咨询”的情感咨询机构诈骗4万余元。

    语文