Java Examples Embedded System Software

Slides:



Advertisements
Similar presentations
Strings An extension of types A class that encompasses a character array and provides many useful behaviors Chapter 9 Strings are IMMUTABLE.
Advertisements

CSE2102 Introduction to Software Engineering Lab 2 Sept/4/2013.
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
The Activity Class 1.  One application component type  Provides a visual interface for a single screen  Typically supports one thing a user can do,
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Programming 2 CS112- Lab 2 Java
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Android Development (Basics)
Chien-Chung Shen Manifest and Activity Chien-Chung Shen
Software Architecture of Android Yaodong Bi, Ph.D. Department of Computing Sciences University of Scranton.
Android Activities 1. What are Android Activities? Activities are like windows in an Android application An application can have any number of activities.
Android Programming-Activity Lecture 4. Activity Inside java folder Public class MainActivity extends ActionBarActivity(Ctrl + Click will give you the.
Android - Broadcast Receivers
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml.
Networking: Part 1 (Web Content). Networking with Android Android provides A full-featured web browser based on Chromium, the open source browser engine.
Activity Android Club Agenda Hello Android application Application components Activity StartActivity.
Characters and Strings. Characters  New primitive char  char letter; letter = ‘a’; char letter2 = ‘C’;  Because computers can only represent numbers,
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Android Application Lifecycle and Menus
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
Android Alert Dialog. Alert Dialog Place Button to open the dialog. public class MainActivity extends ActionBarActivity { private static Button button_sbm;
Speech Service & client(Activity) 오지영.
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Introduction to programming in java
Lab7 – Appendix.
Introduction to android
Android Application -Architecture.
Lab7 – Advanced.
Concurrency in Android
Adapting to Display Orientation
Android Boot Camp for Developers Using Java, 3E
Activities, Fragments, and Events
CS499 – Mobile Application Development
Activities and Intents
Android Mobile Application Development
Programming in Java Text Books :
Android Widgets 1 7 August 2018
ITEC535 – Mobile Programming
The Android Activity Lifecycle
Anatomy of an Android Application
Picasso Revisted.
CIS 470 Mobile App Development
Software Engineering for Internet Applications
Android Programming Lecture 4
CIS 470 Mobile App Development
Chapter 7: Strings and Characters
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Activity Lifecycle Fall 2012 CS2302: Programming Principles.
CMPE419 Mobile Application Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Activities and Intents
Activities and Intents
HNDIT2417 Mobile Application Development
16 Strings.
Android Programming Tutorial
CIS 470 Mobile App Development
Activity Lifecycle.
CIS 493/EEC 492 Android Sensor Programming
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Activities and Intents
SE4S701 Mobile Application Development
CMPE419 Mobile Application Development
Activities and Fragments
In Java, strings are objects that belong to class java.lang.String .
Activities, Fragments, and Intents
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Java Examples Embedded System Software Dept. of Computer Science and Engineering Sogang University, Seoul, KOREA

Android Architecture Java C or C++

Import Project

Import Project

Intent An intent is an abstract description of an operation to be performed Structure The primary pieces of information Action The general action to be performed, such as ACTION_VIEW, ACTION_EDIT, ACTION_MAIN, etc. Data The data to operate on, such as a person record in the contacts database, expressed as a Uri.

Activity 안드로이드에서 ‘화면 하나’라고 이해하는 것이 가장 직관적 lifecycle OnCreate() Called when the activity is first created OnStart() Called when the activity is becoming visible to the user OnResume ( ) Called when the activity will start interacting with the user OnPause ( ) Called when the system is about to start resuming a previous activity OnStop() Called when the activity is no longer visible to the user OnDestroy() The final call you receive before your activity is destroyed public View findViewById (int id) Finds a view that was identified by the id attribute from the XML

Activity Start activity Intent intent = new Intent( this, A.class);

Activity2개를 사용하는 예제 res/layout/activity_main.xml을 res/layout/activity_main2.xml로 복사 res/layout/activity_main2 더블클릭 TextView를 클릭

Activity2개를 사용하는 예제(Cont.) ‘Properties’ window TextView / text ‘activity2’로 변경

Activity2개를 사용하는 예제(Cont.) File / New / File src / com / example / helloworld 선택 File name : MainAcitivity2.java MainActivity2.java 작성 package com.example.androidexample; import android.app.Activity; public class MainActivity2 extends Activity{ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); }

Activity2개를 사용하는 예제(Cont.) AndroidManifest.xml 더블클릭 Application 탭에서 Application Nodes / Add… /Activity Application 탭에서 Attributes for … / Name의 Browse / MainAcitivity2

Activity2개를 사용하는 예제(Cont.) res/layout/activity_main.xml 더블클릭 Button 추가 Button 클릭 ‘Properties’ 윈도우 Id : @+id/newactivity

Activity2개를 사용하는 예제(Cont.) MainActivity.java 수정

Button fragment_main.xml Add two buttons with id btn1 text hello, btn2 world

MediaPlayer MainActivity에 MediaPlayer mp1, mp2 선언 Shift+ctrl+O res/raw/ 폴더 생성 후 hello.mp3, world.mp3 복사 onCreate()에 MediaPlayer.create(this, R.raw.songName);을 통해 MediaPlayer 생성

Button.OnClickListener

TextView MainActivity에 TextView tv; tv = (TextView)findViewById(R.id.textView1); public final void setText (CharSequence text) Sets the string value public CharSequence getText () Return the text the TextView is displaying.

ScrollView activity_main.xml MainActivity.java

Making Buttons Dynamically \

Application 파일구조 res/drawable/ : image 파일 res/layout/ : 화면 구성 xml 파일 res/values/ : string 등 src/ : source AndroidManifest.xml Activity, Service를 정의하고 그 메타데이터들을 제공

String An immutable sequence of characters/code units (chars) Methods charAt(int index) Returns the char value at the specified index. equals(Object anObject) Compares this string to the specified object. contains(CharSequence s) Returns true if and only if this string contains the specified sequence of char values length() Returns the length of this string. substring(int beginIndex, int endIndex) Returns a new string that is a substring of this string. toCharArray() Converts this string to a new character array. static String valueOf(int i) Returns the string representation of the int argument.

String String str = "abcdefg"; str.charAt(3); // d str.equals("abcdefg"); // true str.contains("cde"); // true str.length(); // 7 str.substring(2); // cdefg String.valueOf(1234); // 1234

FileReader MainActivity.java FileReader fis 를 MainActivity에 추가