Optimizing AI for immediate response in Smart CCTV
Â
Introduction to android
1. TOPICS TO BE COVERED
âą Introduction to android.
âą Setup android environment.
âą User interface development.
âą Interactive application development.
2. OVERVIEW
âą What is android?
âą History of android.
âą What is Open handset alliance?
âą Different Versions of android.
3. BRIEF HISTORY
âą Android is a Linux-based open source software stack that comes along with:
1. operating system
2. middleware
3. native mobile applications
âą It was designed primarily for touchscreen mobile devices such as smartphones, tablets.
âą Initially developed by Android Inc.,(founded in 2003 and is based in Palo Alto,
California) which operated as subsidiary of Google and later purchased by Google in
2005.
âą Android was publically announced in 2007 and first phone was sold on October 2008.
5. NAMES & SPECIFICATION
âą Initial two versions were called as beta versions specified as Android 1.0 & 1.1.
âą Later on names of subsequent versions were based on some dessert & are in alphabetic orders
e.g.
1. 1.5 Cupcake
2. 1.6 Donut
3. 2.0/2.1 Ăclair
4. 2.2 Froyo
5. 2.3 Gingerbread
6. 3.0/3.1 Honeycomb
7. 4.0 Ice-cream Sandwich
8. 4.1 Jelly Bean
9. 4.4 Kitkat
8. OPEN SOURCE
Industry
âą Software stack open-
sourced under Apache
2.0 license
âą Source available after
first handsets ship
âą Anyone will be able to
build a system image
Users
âą Users have control of their
experience
âą They control what gets
installed
âą They choose the defaults
Developer
âą Don not need
permission to ship an
application
âą No hidden or privileged
framework APIs
âą Can integrate, extend
and replace existing
components
INDUSTRY
USER
DEVELOPER
10. USER INTERFACE
âą User interface layout
âą View
âą View group
âą UI attributes and ID
âą Types of layouts
âą Basic Input controls
I. Buttons
II. Textfields
III. Radio button
IV. Checkbox
V. Toggle button
VI. Spinners
VII. Pickers
12. View & view group
What is view?
âą All user interface elements in the android app are build using view
and view group objects.
e.g. view contains: button, textfields, etc.
14. For Example Vertical layout in which Button and Text View look
like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a TextView" />
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a Button" />
</LinearLayout>
15. ATTRIBUTES
âą Id: every view element has a unique id.
Example
android:id=â@+id/unique nameâ
Indicates
xml should
be parsed
Indicates new
resource has to added
to R.java file
Resource
generated
automatically
16. LAYOUT AND ITS TYPES
âą Linear
âą Relative
âą Table layout
âą Grid layout
âą Grid view
âą List view
17. LINEAR LAYOUT
âą LinearLayout is a view group that aligns all children in a single
direction, vertically or horizontally. You can specify the layout
direction with the android :orientation attribute.
Example:
22. LIST VIEW
âą List view a view group that displays a list of scrollable items.
âą The list using an adapter that pulls content from a source such as an
array or database query and converts each item result into a view
thatâs placed into the list.
23. GRID VIEW
âą Grid view is a view group that displays items in a two dimensional,
scrollable grid. The grid items are automatically inserted to the layout
using list adapter.
24. Control Type Description Related Classes
Button A push-button that can be pressed, or clicked, by
the user to perform an action.
Button
Text field An editable text field. You can use
theAutoCompleteTextView widget to create a text
entry widget that provides auto-complete
suggestions
EditText,AutoCompleteTextView
Checkbox An on/off switch that can be toggled by the user.
You should use checkboxes when presenting users
with a group of selectable options that are not
mutually exclusive.
CheckBox
Radio button Similar to checkboxes, except that only one option
can be selected in the group.
RadioGroup
RadioButton
Toggle button An on/off button with a light indicator. ToggleButton
Spinner A drop-down list that allows users to select one
value from a set.
Spinner
Pickers A dialog for users to select a single value for a set
by using up/down buttons or via a swipe gesture.
Use aDatePickercode> widget to enter the values
for the date (month, day, year) or
a TimePicker widget to enter the values for a time
(hour, minute, AM/PM), which will be formatted
DatePicker,TimePicker
33. public void sendMessage(View view)
{
// Do something in response to button click
}
The method you declare in the android:onClick attribute must have a
signature exactly as shown above. Specifically, the method must:
âą Be public
âą Return void
âą Define a View as its only parameter
34. USING Onclicklistener
Button button = (Button) findViewById(R.id.button_send);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Do something in response to button click
}
});
35. CHECKBOX
public void
onCheckboxClicked(View view) {
// Is the view now checked?
boolean checked = ((CheckBox)
view).isChecked();
// Check which checkbox
was clicked
switch(view.getId()) {
case R.id.checkbox_meat:
if (checked)
// Put some meat on
the sandwich
else
// Remove the meat
break;
case R.id.checkbox_cheese:
if (checked)
// Cheese me
else
// I'm lactose intolerant
break;
// TODO: Veggie sandwich
}}
37. ONCLICK EVENT
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.radio_pirates:
if (checked)
// Pirates are the best
break;
case R.id.radio_ninjas:
if (checked)
// Ninjas rule
break;
}}
38. Important Folders
âą Whenever we create any Application, there are a number of folders which are created by default.
âą These folders contain subfolders and important files associated to them which play a key role in proper UI designing as
well as coding.
1. src (source code of activities)
2. Android 4.4 (contains all library files)
3. gen ( auto generated files (R.java))
4. Res (resource)
1. it contains all Drawable components
2. layouts ( it contains the xml file)
3. menu
4. values â string.xml
dimens.xml
style.xml
5. Android Manifest File
1. Sdk (min to max)
2. Application (contain main activity details)
a. Activity
b. Intent filter
c. Providers
d. Services
e. Receivers etc.
39.
40. Image View
1. If we want to add an Image in our activity, we need to copy the
image to the âDrawable folderâ in âres folderâ.
2. Drawable folder contains subfolders :
1. hdpi ( ÌŽ 240 dpi) is High density pixels
2. ldpi ( ÌŽ 120 dpi) is Low density pixels
3. mdpi ( ÌŽ 160 dpi) is medium density pixels
4. xhdpi ( ÌŽ 320 dpi) is extra high density pixels
3. Add <imageView> and define different parameters in it.
41. Toast Message (notification)
âą Toast provides simple feedback about an operation in a small popup.
âą It only fills the amount of space required for the message and the current activity
remains visible and interactive.
âą Toast automatically disappears after timeout.
Syntax : Toast toast=Toast.makeText (context, text, duration);
toast.show();
Note:- Toast is instantiated by using makeText() method.