FIT2081 Lecture Notes - Lecture 2: Open Handset Alliance, Android Studio, Manifest File

237 views4 pages
!"#$%&#'
()*&"&+&%"
,
!$-.&+)-+/$)0
1&"/203)$")4056
!"#$%&#07+8-30948:)$7;
,
5<!095=)"0<8"#7)+0!44&8"-);
,
>-%7:7+)?
,
,
6/==%$+01&D$8$&)709!617;
,
E$8F?)"+8+&%"
()G&-)04)G)4
,
!BC04)G)4
,
H%?=8+&D&4&+:
E%$I8$#09%4#08==70%"0")I)$0G)$7&%"7;
,
J8-3I8$#09")I08==70%"0%4#)$0G)$7&%"7;
,
!==07+$/-+/$)'
6K1&+)09#8+8D87);LM
N)*)$)"-)70O*&$7+0%")07.4#0D)08+0#)G)4%=)$M8"#$%&#M-%?PM
!-+&G&+:
startActivity(Intent intent)
7+8$+7080")I0&"7+8"-)0%*08"0!-+&G&+:
QM
6)$G&-)7RM
HB7SM
HN0T%"4:0LUM
J$%8#-87+0$)-)&G)$7VM
!-+&G8+&"F0-%?=%")"+7'
C"+)"+
getIntent(Intent intent) $)+/$"70+.)0&"+)"+0 +.8+07+8$+)#0+.&708-+&G&+:
intent.getStringExtra(String s) %D+8&"70W/)$:0 7+$&"F0*$%?0
&"+)"+M!HXC5YZ6>!NH<
intent.putExtra(String key,[Anything] value) =/+70)2+$80#8+80+%0
D)0+$8"7*)$$)#0I&+.0+.)0&"+)"+
P0+:=)7'
!-+&G&+:0&"+)"+
H8"07)"#0*$%?0%")08==0+%08"%+.)$0)G)"0&*0%+.)$08==0
&7"[+0$/""&"F
\
C?=4&-&+'07+8+)70+:=)0%*08-+&%" +%0=)$*%$?05N0=$%G&#)70
#8+8 %*0807=)-&*&-0+:=)0%"0I.&-.0+.)08-+&%"0&70+%0D)0
=)$*%$?)#
\
>2=4&-&+'0 N)W/)7+7048/"-.0%*07=)-&*&-08-+&G&+:0D:0
$)*)$)"-&"F0&+0D:0&+70-48770"8?)
\
§
J$%8#-87+0&"+)"+
6)"+07:7+)?OI&#)+%084408==70+.8+0.8G)0$)F&7+)$)#08"0
]&"+)$)7+)#]0D$%8#-87+0$)-)&G)$
\
X%0&"#&-8+)0-.8"F)70&"0#)G&-)07+8+/7\
§
,
C"+)$O8==08-+&G8+&%"
E%$0)28?=4)A07.8$&"F0=.%+%70*$%?0^844)$:0+%0_!
()4&G)$70?7F0+%07:7+)?07=)-&*:&"F0&"+)"+0+%07+8$+0+.8+0=8$+&-/48$0
-%?=%")"+
,
HB09D:0$)W/)7+0*$?0HN;
H%?=%")"+0#%&"F0+$8"78-+&%"70I`0HB0-8"0-8440?)+.%#70%"0HN0
%DaA04)8G&"F08048:)$0%*08D7+$8-+&%"0D)+I))"0HB08"#0&+7)4*09*%$0
7)-/$&+:;
,
!==0?8"&*)7+0*&4)
N)7%/$-)0*&4)7
!==4&-8+&%"0H%"+)2+
!"#$%&#06+/#&%
b8G80G70!"#$%&#'
@c709@&$+/840c8-.&")7;,
H487701&D$8$&)7,
dC0!BC7,
LinearLayout
e08048:%/+0+.8+08$$8"F)70%+.)$0
G&)I70)&+.)$0.%$&f%"+844:0&"080
7&"F4)0-%4/?"A0%$0G)$+&-844:0&"080
7&"F4)0$%I
layout_width/height
,
paddingLeft/Right
,
orientation
,
gravity
,
EditText(Context)
e080/7)$0&"+)$*8-)0)4)?)"+0*%$0
)"+)$&"F08"#0?%#&*:&"F0+)2+
android:id
B$%G&#)70/"&W/)0&#)"+&*&)$0*%$0
+.)0@&)IA0I.&-.0-8"0D)0/7)#0+%0
$)*)$)"-)0+.)0%Da0*$?0+.)08==0
-%#)09+%0$)8#A0?8"&=0%Da;
,
android:layout_height/width
android:inputType="text"
Button
e0-%"7&7+0%*080+)2+0%$0&-%"09%$0D%+.;0+.8+0-%??/"&-8+)70I.8+08-+&%"70%--/$70
I.)"0+.)0/7)$0+%/-.)70&+
android:layout_height/width
android:text="@string/button_text"
android:src="@drawable/button_icon"
android:drawableLeft="@drawable/button_icon"
button.setOnClickListener(new View.onClickListener() {
public void onClick (View v) {
// do something
}
});
Why$and$how$does$API$fragmentation$happen?
6&"-)0!"#$%&#0&70%=)"07%/$-)A0.8$#I8$)0=$%G&#)$70+.8+0/7)0!"#$%&#0.8G)0+%0
+8&4%$0")I0$)4)87)70%*0!"#$%&#0*%$0+.)&$0#)G&-)7`-/7+%?)$7A04)8#&"F0+%080
7+8FF)$)#0$)4)87)0%*0!"#$%&#0G)$7&%"708"#0#)G&-)708$)074%I0+%0F)+0!"#$%&#0
/=#8+)7M
E%$0)28?=4)A0&*08"0!"#$%&#0/=#8+)0&70$)4)87)#'
^%%F4)0.8$#I8$)09)FM0B&2)4;0&70/=#8+)#07+$8&F.+8I8:,
<8$#I8$)0=$%G&#)$709)FM068?7/"F;0?83)0-.8"F)70+%0.8$#I8$)0?8:D)0
80?%"+.08*+)$
,
H%/4#0D)0*/$+.)$0#)48:)#0D:0-.8"F)70?8#)0D:0?%D&4)0-8$$&)$,
Activities$VS$Services$in$Android:
!-+&G&+:0/7/844:0-%$$)48+)70+%0807&"F4)0/7)$0&"+)$*8-)07-$))"gLM
6)$G&-)0#%)7"[+0=$%G&#)0/7)$0&"+)$*8-)
!-+&G&+:0&70807&"F4)A07+8"#84%")0?%#/4)0%*08==0*/"-+&%"84&+:0$/""&"F0&"0
+.)0*%$)F$%/"#
PM
6)$G&-)0$/"70&"0+.)0D8-3F$%/"#
Activity$Intent$main$usage
e0?)-.8"&7?0D:0I.&-.0%")0!-+&G&+:0&708D4)0+%048/"-.08"%+.)$0!-+&G&+:`6)$G&-)0
8"#0&?=4)?0+.)0*4%I0+.$%/F.0+.)0!-+&G&+&)70+.8+0?83)0/=0+.)08==
Broadcast$Intent$main$usage
e0807:7+)?OI&#)0&"+)"+07)"+0%/+0+%084408==70+.8+0.8G)0$)F&7+)$)#08"0
]&"+)$)7+)#]0J$%8#-87+0N)-)&G)$
What$is$the$easiest$way$to$update$various$characteristics$of$app$without$
modifying$code,$if$developing$an$app$targeting$devices$with$small$and$
large$screen$sizes?
B$%G&#)084+)$"8+&G)0$)7%/$-)0*&4)709+.8+0-8"0D)08#a/7+)#0G&80hc1;07)=8$8+)0
*$%?0:%/$07%/$-)0-%#)A0+.8+0-8"0D)0/7)#0+%0%=+&?&7)0:%/$08==0*%$0#&**)$)"+0
#)G&-)0-%"*&F/$8+&%"7A0*%$0)28?=4)0#&**)$)"+07-$))"07&f)70%$0%$&)"+8+&%"7M
To$reference$a$resource$from$your$app$code,$what$should$you$use?
d"&W/)0&"+)F)$0C(M
Consider$an$app$compiled$against$API$level$22$on$a$device$running$Nougat.
This$usually$works.$Why?
X.)0!BC0G)$7&%"08*+)$0!BC0G)$7&%"0U099Y%/F8+0&70G)$0V;0I%"[+0-.)-30+.)0
?82&?/?0G)$7&%"0*%$08"08==M
How$could$this$go$wrong?
6%?)07=)-&840*)8+/$)70*%$0!BC04)G)40PP0-%/4#0=%77&D4:0"%+0D)08D4)0+%0%=)$8+)0
%"0Y%/F8+M
Can$it$be$fixed$without$changing$API$level$of$the$app$or$device?$Explain.
!"#$%&#08==708$)0F)")$844:0*%$I8$#O-%?=8+&D4)0I&+.0")I0G)$7&%"70%*0+.)0
!"#$%&#0=48+*%$?A07&"-)084?%7+08440-.8"F)70+%0+.)0*$8?)I%$30!BC08$)0
8##&+&G)M
Consider$an$app$compiled$against$API$25$on$a$device$running$Lollipop.
How$could$this$go$wrong?
!"#$%&#08==708$)0"%+0")-)778$&4:0D8-3I8$#O-%?=8+&D4)0I&+.0G)$7&%"70%*0+.)0
!"#$%&#0=48+*%$?0%4#)$0+.8"0+.)0G)$7&%"08F8&"7+0I.&-.0+.):0I)$)0-%?=&4)#M0
>8-.0")I0G)$7&%"0%*0+.)0!"#$%&#0=48+*%$?0-8"0&"-4/#)0")I0*$8?)I%$30!BC7M
If$it$goes$wrong,$can$it$be$fixed$always$or$sometimes?$Under$what$
circumstances$can$it$be$fixed?
H8"084I8:70D)0*&2)#0&*0+.)08==4&-8+&%"0.8707/==%$+04&D$8$&)7M
6/==%$+01&D$8$&)70=$%G&#)08##&+&%"840-%"G)"&)"-)0-4877)708"#0*)8+/$)70"%+0
8G8&48D4)0&"0+.)07+#0E$8?)I%$30!BC0*%$0)87&)$0#)G)4%=?)"+08"#07/==%$+0
8-$%770?%$)0#)G&-)7M
An$Android$app$needs$to$store$its$data$in$a$relational$db$and$share$it$with$
other$apps.$What$components$and$classes$do$you$need?
HB70e0&?=4)?)"+080?)-.8"&7?0*%$0#8+8O7.8$&"F0D)+I))"08==7
!":08==0-8"0=$%G&#)0%+.)$08==70I&+.08--)770+%0&+70/"#)$4:&"F0
#8+80+.$%/F.0+.)0&?=4)?)"+8+&%"0%*080HBA0&"-4/#&"F08D&4&+:0+%0
8##A0$)?%G)08"#0W/)$:0#8+8097/Da)-+0+%0=)$?&77&%"7;
!--)770+%0#8+80=$%G&#)#0G&80dNC09d"&G)$7840N)7%/$-)0C#)"+&*&)$;0
#)*&")#0D:0HB
(8+807.8$)#0&"0+.)0*%$?0%*080*&4)0%$0)"+&$)06K1&+)0#D
,
HN,
=/D4&-08D7+$8-+0-48770H%"+)"+B$%G&#)$,
8"#$%&#M-%"+)"+M-%"+)"+B$%G&#)$,
What$app$components$can$be$activated$by$an$intent?
!-+&G&+&)7A06)$G&-)7A08"#0J$%8#-87+0N)-)&G)$7M
Week$2
X/)7#8:A0 Pi0c8:0PjLk
Lj'QQ
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Document Summary

= a layout that arranges other views either horizontally in a single column, or vertically in a single row layout_width/height paddingleft/right orientation gravity. = a user interface element for entering and modifying text android:id. Provides unique identifier for the view, which can be used to reference the obj frm the app code (to read, manip obj) android:layout_height/width android:inputtype=text = consist of a text or icon (or both) that communicates what actions occurs when the user touches it android:layout_height/width android:text=@string/button_text android:src=@drawable/button_icon android:drawableleft=@drawable/button_icon android:drawableleft=@drawable/button_icon button. setonclicklistener(new view. onclicklistener() { public void onclick (view v) { Intent getintent(intent intent) returns the intent that started this activity intent. getstringextra(string s) obtains query string from intent. action_search intent. putextra(string key,[anything] value) puts extra data to be transferred with the intent. Can send from one app to another even if other app isn"t running. Implicit: states type of action to perform or provides data of a specific type on which the action is to be performed.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers