1 / 22

ISAC – Android programming

ISAC – Android programming. International summer academic course U nivesity of nis. ISAC – Android programming. Introductions into Android programming SDK (Sowtware developement kit) DVM(Dalvik Virtual Machine) JAVA API Eclipse Android App Fundamentals

rio
Télécharger la présentation

ISAC – Android programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ISAC – Android programming International summer academic course Univesity of nis

  2. ISAC – Android programming • Introductions into Android programming • SDK (Sowtware developement kit) • DVM(Dalvik Virtual Machine) • JAVA API • Eclipse • Android App Fundamentals • The process of creating an android application • Android SDK configuration • Creating a new virtual device

  3. ISAC – Android programming Setup Set up your developement environment Install the Android SDK, Android Developement Tools and Android platforms Create Android Virtual Devices and connect hardware devices for testing Set up AVDs and devices for testing Create an Android project with your source code, resources and manifest file Create your application • Developement

  4. ISAC – Android programming Debugging and testing Build and run your application Build and run your application in debug mode Debug your application using the Android debugging and logging tools Debugg your application Test your application using emulator or real devices Test your application

  5. ISAC – Android programming Publishing Prepare your application for release Configure, build and test your application in release mode Publicize, sell and distribute your application to users Debugg your application

  6. ISAC – Android programming • Android SDK • Configuring Android SDK manager • Creating virtual devices • Getting to know the environment • Creating a new Android project and a  “Hello world” application

  7. ISAC – Android programming What is an activity? Layouts Manifest XML R class

  8. ISAC – Android programming Activity • The basis of android applications • A single Activity defines a single viewable screen • the actions, not the layout • Can have multiple per application • Each is a separate entity • They have a structured life cycle • Different events in their life happen either via the user touching buttons or programmatically

  9. ISAC – Android programming Life cycle of an activity

  10. ISAC – Android programming Project components • src – your source code • gen – auto-generated code (usually just R.java) • Included libraries • Resources • Drawables (like .png images) • Layouts • Values (like strings) • Manifest file

  11. ISAC – Android programming XML – Extensible Markup Language • Used to define some of the resources • Layouts (UI) • Strings • Manifest file • Shouldn’t usually have to edit it directly, Eclipse can do that for you • Preferred way of creating UIs • Separates the description of the layout from any actual code that controls it • Can easily take a UI from one platform to another

  12. ISAC – Android programming R class • Auto-generated: you shouldn’t edit it • Contains IDs of the project resources • Enforces good software engineering • Use findViewById and Resources object to get access to the resources • Ex. Button b = (Button)findViewById(R.id.button1) • Ex. getResources().getString(R.string.hello));

  13. ISAC – Android programming Mafinest file • Contains characteristics about your application • When have more than one Activity in app, NEED to specify it in manifest file • Go to graphical view of the manifest file • Add an Activity in the bottom right • Browse for the name of the activity • Need to specify Services and other components too • Also important to define permissions and external libraries, like Google Maps API

  14. ISAC – Android programming UI, layouts and components used in Android apps Layouts • Eclipse has a great UI creator • Generates the XML for you • Composed of View objects • Can be specified for portrait and landscape mode • Use same file name, so can make completely different UIs for the orientations without modifying any code • Types of layouts: Linear, Relative, Frame...

  15. ISAC – Android programming UI, layouts and components used in Android apps Layouts • Eclipse has a great UI creator • Generates the XML for you • Composed of View objects • Can be specified for portrait and landscape mode • Use same file name, so can make completely different UIs for the orientations without modifying any code • Types of layouts: Linear, Relative, Frame...

  16. ISAC – Android programming 1. Intents and intent filter 1.1. What are intents? 1.2. Starting activities

  17. ISAC – Android programming The following code demonstrates how you can start another activity via an intent. # Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.class); startActivity(i);

  18. 2. Intents types 2.1. Different types of intents 2.2. Explicit Intents Explicit intents explicitly define the component which should be called by the Android system, by using the Java class as identifier. 2.3. Implicit Intents Implicit intents specify the action which should be performed and optionally data which provides content for the action.

  19. 3. Data transfer between activities 3.1. Data transfer to the target component Bundle extras = getIntent().getExtras(); if (extras == null) { return; } // get data via the key String value1 = extras.getString(Intent.EXTRA_TEXT); if(value1 != null) { // do something with the data }

  20. 3.2. Example: Using the share intent // this runs, for example, after a button click Intent intent = newIntent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(android.content.Intent.EXTRA_TEXT, "News for you!"); startActivity(intent);

  21. 3.3. Retrieving result data from a sub-activity

More Related