Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ndk:courses:01 [2014/02/25 16:01]
laura.gheorghe [Lecture]
ndk:courses:01 [2014/11/05 11:54] (current)
laura.gheorghe
Line 3: Line 3:
   * Description:​ General overview of the Android OS, layers and tools   * Description:​ General overview of the Android OS, layers and tools
   * Practical part: Android tools, emulators, ADB, Beacon Mountain   * Practical part: Android tools, emulators, ADB, Beacon Mountain
 +
  
 ==== Lecture ==== ==== Lecture ====
  
  
-  *[[ndk:​courses:​lecture-1.pdf | Lecture Slides]]+  *{{:ndk:​courses:​lecture-1.pdf | Lecture Slides}} 
 + 
 +{{url>​http://​ocw.cs.pub.ro/​courses/​_media/​ndk/​courses/​lecture-1.pdf}}
  
-<​HTML>​ 
-<iframe src="​http://​docs.google.com/​viewer?​url=ndk:​lecture-1.pdf&​embedded=true"​ width="​600"​ height="​470"​ style="​border:​ none;"></​iframe>​ 
-</​HTML>​ 
 ==== Practical ==== ==== Practical ====
  
Line 29: Line 29:
 === Task 0 - Setting up the environment === === Task 0 - Setting up the environment ===
  
-This section is meant you help you set up your enviroment ​at home. All links are found in the resources.+This section is meant you help you set up your environment ​at home. All links are found in the resources.
  
-There are two ways of setting up your environment. The first way is using Intel'​s Beacon Mountain for Android solution. This sets up your whole enviroment ​including SDK and NDK and contains some additional profiling tools and HAXM, needed for virtualizing Intel Atom based virtual devices. Run the installer and follow the steps.+There are two ways of setting up your environment. The first way is using Intel'​s Beacon Mountain for Android solution. This sets up your whole environment ​including SDK and NDK and contains some additional profiling tools and HAXM, needed for virtualizing Intel Atom based virtual devices. Run the installer and follow the steps.
  
 The second way will set up the bare minimum needed for creating an NDK project. ​ The second way will set up the bare minimum needed for creating an NDK project. ​
Line 136: Line 136:
  
 Add the following code to the onCreate method. Make sure the ids match the ones in your layout. Add the following code to the onCreate method. Make sure the ids match the ones in your layout.
-<​code>​+<​code ​Java>
         final Button b1 = (Button) findViewById(R.id.button1);​         final Button b1 = (Button) findViewById(R.id.button1);​
         final TextView tv1 = (TextView) findViewById(R.id.textView1);​         final TextView tv1 = (TextView) findViewById(R.id.textView1);​
Line 153: Line 153:
 === Task 5 - Use logcat for debugging === === Task 5 - Use logcat for debugging ===
  
-Start the application installed in Task 3. Make sure the **Logcat** tab is the one selected in the panel at the bottom. Type any text in the box and then click one of the buttons. A new line containing your text should appear in the **Logcat**. Depending on what button you press, the line colour will vary. It is also possible to filter these log entries: above the logs themselves there is a text entry input which allows textual filtering. It allows you to limit scope by prefixing searches with pid:, tag:, app: or text: and it accepts Java-style regular expressions. To the right of this text field there is a dropdown which allows you to select verbosity. Choosing a level will only allow messages of that level or higher to be displayed.+Start the application installed in Task 2. Make sure the **Logcat** tab is the one selected in the panel at the bottom. Type any text in the box and then click one of the buttons. A new line containing your text should appear in the **Logcat**. Depending on what button you press, the line colour will vary. It is also possible to filter these log entries: above the logs themselves there is a text entry input which allows textual filtering. It allows you to limit scope by prefixing searches with pid:, tag:, app: or text: and it accepts Java-style regular expressions. To the right of this text field there is a dropdown which allows you to select verbosity. Choosing a level will only allow messages of that level or higher to be displayed.
  
 Import the LogLevel project into Eclipse (**File > Import** and select **General > Existing project into workspace**). Look over the code. Each button has a method attached which calls a static method from the Log class. These methods generate log entries on different levels of importance: d=debug, i=info, w=warning, e=error. Import the LogLevel project into Eclipse (**File > Import** and select **General > Existing project into workspace**). Look over the code. Each button has a method attached which calls a static method from the Log class. These methods generate log entries on different levels of importance: d=debug, i=info, w=warning, e=error.
  
 Add another two buttons to the application:​ one that generates an assert level log entry, and one that repeats the previously generated log entry, but with a higher level of importance, except in the case of assert, which will remain the same. Add another two buttons to the application:​ one that generates an assert level log entry, and one that repeats the previously generated log entry, but with a higher level of importance, except in the case of assert, which will remain the same.
 +
 +=== Task 6 - View weight ===
 +
 +Use the LogLevel project as a start. Notice that the EditText box only takes up one line of the screen and there should be some screen space left at the bottom of the screen. Make the EditText box take up all available space. To do this, you should set the weight parameter of the EditText view to 1 (or any integer).
 +
 +The weight parameter is used to distribute empty screen space to the elements which need it. First, the layout builder will place all the elements for which the size is easy to determine. Then, the empty space will be distributed to the elements with weight, based on their weight: if the total weight of all elements is 4, an element with a weight of 1 will get 1/4 of the empty screen space, an element with 2 weight will get 2/4, and so on.
 +
 +=== Task 7 - Multiple resources ===
 +
 +In Android you can have multiple resources with the same ID. This allows building a single application for all the languages, screen resolutions or formats, and have the system select the correct resource when running the application.
 +
 +In the LogLevel project, notice that there is a single **layout** folder. Modify this layout to fit two screen densities: mdpi and hdpi. To do this, rename the folder **layout** to **layout-hdpi** and make a copy of it named **layout-mdpi**. This will allow the system to select the mdpi layout for systems with medium dpi or lower, and the hdpi layout for the rest. Modify the mdpi layout to display the buttons on two columns instead of a single button on each row. Use multiple horizontal LinearLayouts.
ndk/courses/01.1393336887.txt.gz · Last modified: 2014/02/25 16:01 by laura.gheorghe
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0