Lab 1 – Introduction to Android & Hello World Example
KUAN-TING LAI 2018/9/10
Lab 1 Introduction to Android & Hello World Example KUAN-TING - - PowerPoint PPT Presentation
Lab 1 Introduction to Android & Hello World Example KUAN-TING LAI 2018/9/10 Android History Code Version Linux kernel Initial release API version [1] name number date level (No codename) [2] 1.0 ? September 23, 2008 1 Petit
Lab 1 – Introduction to Android & Hello World Example
KUAN-TING LAI 2018/9/10
Code name Version number Linux kernel version[1] Initial release date API level (No codename)[2] 1.0 ? September 23, 2008 1 Petit Four[2] 1.1 2.6.X February 9, 2009 2 Cupcake 1.5 2.6.27 April 27, 2009 3 Donut[3] 1.6 2.6.29 September 15, 2009 4 Eclair[4] 2.0 – 2.1 2.6.29 October 26, 2009 5 – 7 Froyo[5] 2.2 – 2.2.3 2.6.32 May 20, 2010 8 Gingerbread[6] 2.3 – 2.3.7 2.6.35 December 6, 2010 9 – 10 Honeycomb[7] 3.0 – 3.2.6 2.6.36 February 22, 2011 11 – 13 Ice Cream Sandwich[8] 4.0 – 4.0.4 3.0.1 October 18, 2011 14 – 15 Jelly Bean[9] 4.1 – 4.3.1 3.0.31 to 3.4.39 July 9, 2012 16 – 18 KitKat[10] 4.4 – 4.4.4 3.10 October 31, 2013 19 – 20 Lollipop[11] 5.0 – 5.1.1 3.16.1 November 12, 2014 21 – 22[12] Marshmallow[13] 6.0 – 6.0.1 3.18.10 October 5, 2015 23 Nougat[14] 7.0 – 7.1.2 4.4.1 August 22, 2016 24 – 25 Oreo[15] 8.0 – 8.1 4.10 August 21, 2017 26 – 27 Pie[16] 9.0 4.4.107, 4.9.84, and 4.14.42 August 6, 2018 28
Courtesy: https://en.wikipedia.org/wiki/Android_version_history
❖ View System ❖ Resource Manager ❖ Notification Manager ❖ Activity Manager ❖ Content Providers
https://developer.android.com/guide/components/fundamentals
Activities Handle UI and interact with user Ex: A photo app calls an email app to share photos Services Run background process Ex: Music playback Broadcast Receivers Receive system events Ex: Alarm, battery low, … Content Providers Manage APP data Ex: SQLite database
https://developer.android.com/jetpack/docs/guide
https://developer.android.com/guide/components/activities/intro-activities#java
https://developer.android.com/guide/components/services
https://developer.android.com/guide/components/broadcasts
suggestions through the search framework using SearchRecentSuggestionsProvider
with your server using an implementation of AbstractThreadedSyncAdapter
CursorLoader
https://developer.android.com/guide/components/intents-filters
Implicit Intent Delivery
Fragments Represent a behavior or a portion of user interface in an Activity Views UI elements that are drawn onscreen including buttons, lists forms etc. Layouts View hierarchies that control screen format and appearance
Intents Messages wiring components together Resources External elements, such as strings, constants and drawable pictures Manifest Configuration file for the application
com.aiotlab.helloworld > MainActivity
activity_main.xml
AndroidManifest.xml
build.gradle
Click Download
system-path-check-your-android-sdk-root-value
https://developer.android.com/training/basics/firstapp/building-ui
Change UI Strings
strings.xml
=> value):
message”
Horizontal Chain
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } /** Called when the user taps the Send button */ public void sendMessage(View view) { // Do something in response to button } }
public class MainActivity extends AppCompatActivity { public static final String EXTRA_MESSAGE = "com.aiotlab.kt.helloworld.MESSAGE"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } /** Called when the user taps the Send button */ public void sendMessage(View view) { Intent intent = new Intent(this, DisplayMessageActivity.class); EditText editText = (EditText) findViewById(R.id.editText); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); } }
Context)
carry data types as key-value pairs called extras.
uses the key to retrieve the text value
make unique keys
specified by the Intent
Activity > Empty Activity.
for Activity Name and click Finish (leave all other properties set to the defaults).
layout
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_message); // Get the Intent that started this activity and extract the string Intent intent = getIntent(); String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE); // Capture the layout's TextView and set the string as its text TextView textView = findViewById(R.id.textView); textView.setText(message); }
<activity android:name=".DisplayMessageActivity" android:parentActivityName=".MainActivity"> <!-- The meta-data tag is required if you support API level 15 and lower --> <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity" /> </activity>