Our next book, Sam's Teach Yourself Android Application Development in 24 Hours, Second Edition, is available for pre-order from Amazon. Buy it now and be amongst the first to receive it.
We've made extensive changes throughout the entire book, updating it based on feedback from readers -- including many who have commented on this blog -- as well as incorporating updates and changes to the Android SDK and tools. We appreciate all feedback; keep it coming!
We expect this book to hit shelves sometime mid- to late-August. Amazon is showing a date of August 25, while InformIT is showing a date of August 15.
We hope you enjoy it and learn from it.
My Blog List
Diberdayakan oleh Blogger.
Tampilkan postingan dengan label SAMS. Tampilkan semua postingan
Tampilkan postingan dengan label SAMS. Tampilkan semua postingan
Kamis, 02 Juni 2011
Jumat, 04 Maret 2011
Reader Feedback: Analysis of an Exercise
At the end of each "Hour" in the Sam's Teach Yourself Android Application Development in 24 Hours
book, there are exercises. We originally designed these exercises to be items people could try to extend their knowledge above and beyond what was learned verbatim in the chapter, given some hints and practice using the the Android documentation that is critical to become familiar with.
Here we present one such exercise that occurs in one of the first real coding hours and present our thought process for determining the solution. Hopefully this will help readers who may be struggling with the difficulty of the exercises. That said, we have also determined, based upon reader feedback, that a handful of exercises in the book are perhaps unfairly difficult. For the next edition of the book, many of these will be replaced or labelled as challenge exercises.
Walk-Through of an Exercise
This is from Hour 7 on page 125, if you'd like to follow along. As it's the end of the chapter, you already would have downloaded the code to work along with in the chapter. If not, it's available right here.
Thought Process, Step 1: This tells me we're dealing with something to do with the LayoutAnimationController. Luckily, we just covered that on page 122, where we gave this following code:
Thought Process, Step 2: The code goes in QuizSplashActivity. Since I'm in Hour 7, I've been implementing this activity for the Splash Screen for most of the chapter.
Key Phrase #2: "to apply animations of each child view within a TableRow control"
Thought Process, Step 3: So far so good. The code is already doing that. We found the code in the section labelled, "Animating All Views in a Layout."
Key Phrase #3: "in random order"
Thought Process, Step 4: Hmm, I don't know how to do that. Let me read on, finishing the sentence...
Key Phrase #4: "using the setOrder() method with a value of 2 (random)."
Thought Process, Step 5: Oh, that's how! OK, hold on. I have two options: I could look up this method in the Android SDK docs, or just write it based on what was said in the exercise and see what happens. (Note: We prefer you look it up, like a good student, but experimentation doesn't hurt anything, either.) But perhaps we're lazy so... Let me just add that one line of code to the end of the initial listing, which will now look like:
Run the app and see what happens.... Hey! That's pretty neat. Each time I run it, the animations happen in a different order and sometimes some of them happen at the same time.
Here we present one such exercise that occurs in one of the first real coding hours and present our thought process for determining the solution. Hopefully this will help readers who may be struggling with the difficulty of the exercises. That said, we have also determined, based upon reader feedback, that a handful of exercises in the book are perhaps unfairly difficult. For the next edition of the book, many of these will be replaced or labelled as challenge exercises.
Walk-Through of an Exercise
This is from Hour 7 on page 125, if you'd like to follow along. As it's the end of the chapter, you already would have downloaded the code to work along with in the chapter. If not, it's available right here.
"Exercise #1: Modify the LayoutAnimationController in the QuizSplashActivity class to apply animations of each child view within a TableRow control in random order by using the setOrder() method with a value of 2 (random)."Key Phrase #1: "Modify the LayoutAnimationController in the QuizSplashActivity"
Thought Process, Step 1: This tells me we're dealing with something to do with the LayoutAnimationController. Luckily, we just covered that on page 122, where we gave this following code:
Animation spinin = AnimationUtils.loadAnimation(this, R.anim.custom_anim);
LayoutAnimationController controller = new LayoutAnimationController(spinin);
TableLayout table = (TableLayout) findViewById(R.id.TableLayout01);
for (int i = 0; i < table.getChildCount(); i++) {
TableRow row = (TableRow) table.getChildAt(i);
row.setLayoutAnimation(controller);
}
Thought Process, Step 2: The code goes in QuizSplashActivity. Since I'm in Hour 7, I've been implementing this activity for the Splash Screen for most of the chapter.
Key Phrase #2: "to apply animations of each child view within a TableRow control"
Thought Process, Step 3: So far so good. The code is already doing that. We found the code in the section labelled, "Animating All Views in a Layout."
Key Phrase #3: "in random order"
Thought Process, Step 4: Hmm, I don't know how to do that. Let me read on, finishing the sentence...
Key Phrase #4: "using the setOrder() method with a value of 2 (random)."
Thought Process, Step 5: Oh, that's how! OK, hold on. I have two options: I could look up this method in the Android SDK docs, or just write it based on what was said in the exercise and see what happens. (Note: We prefer you look it up, like a good student, but experimentation doesn't hurt anything, either.) But perhaps we're lazy so... Let me just add that one line of code to the end of the initial listing, which will now look like:
Animation spinin = AnimationUtils.loadAnimation(this, R.anim.custom_anim);
LayoutAnimationController controller = new LayoutAnimationController(spinin);
TableLayout table = (TableLayout) findViewById(R.id.TableLayout01);
for (int i = 0; i < table.getChildCount(); i++) {
TableRow row = (TableRow) table.getChildAt(i);
row.setLayoutAnimation(controller);
}
controller.setOrder(2); // THIS IS THE ONE NEW LINE OF CODE, THE SOLUTION TO EXERCISE #1
Run the app and see what happens.... Hey! That's pretty neat. Each time I run it, the animations happen in a different order and sometimes some of them happen at the same time.
Selasa, 01 Februari 2011
New Feature: Book Code Downloads
Many readers have found it difficult to access the book code downloads from the official publisher site. After some discussion with our editor, we are pleased to inform you that we now have them hosted separately and available for easy, direct download. (No login should be needed and certainly no verification that you own the book. But you already bought it, right? :) )
In addition to providing a new source for downloading the files, we have also provided a single download for all of the code for each book.
The download link is convenient found right next to the Home link above, under "Book Code Downloads."
Happy Android Coding!
In addition to providing a new source for downloading the files, we have also provided a single download for all of the code for each book.
The download link is convenient found right next to the Home link above, under "Book Code Downloads."
Happy Android Coding!
Rabu, 26 Januari 2011
Free Android Development Books!
So head on over there and give it a shot if you haven't taken the dive yourself already. Check out Mobiletuts+ for great Android tutorials, many written by yours truly.
Kamis, 14 Oktober 2010
Reader Feedback: Manifest Permissions Editor
[UPDATE: 13 Feb, 2011: This problem now longer exists in ADT 9.0.0 (the version right after 0.9.9).]
The Android Manifest file editor within Eclipse provides a number of useful editing tabs to wrangle the complexities of this file. One such tab is the Permissions tab. Use the Permissions tab to manage the permissions that your application uses and grants to others.
If you've been working with Android for a while, then you may be familiar with the permissions listed in the drop-down when you register a new permission using the uses-permission tag. We refer to this feature in both our books; specifically in Sam's Teach Yourself Android Application Development in 24 Hours
, Hour 5, "Configuring the Android Manifest File."
Unfortunately, a recent update to the Android Development Tools plugin removed this drop-down. We're not sure if it's a bug or not yet, but the drop-down disappeared in the software update between ADT 0.9.8 or ADT 0.9.9.
What used to look like:
Now looks like:
When you press the Browse... button, the dialog comes up.
The field provided still works for typing in permissions values by hand, instead of selecting them from a list. The alternate method, editing the XML file directly from the last tab, hasn't changed at all.
So where is one to get these values to type in yourself? On page 90 and 91 of the SAMS book, we've listed a number of the most common permission values. However, the best place to get the appropriate values for your applications is from the Android SDK documentation. Permissions are defined in the documentation for the android.Manifest.permission class. Also conveniently listed with these values is a short description of what they enable the application to do. Before including a permission within your application, always check the documentation to determine if that is the most appropriate one to use.
The Android Manifest file editor within Eclipse provides a number of useful editing tabs to wrangle the complexities of this file. One such tab is the Permissions tab. Use the Permissions tab to manage the permissions that your application uses and grants to others.
If you've been working with Android for a while, then you may be familiar with the permissions listed in the drop-down when you register a new permission using the uses-permission tag. We refer to this feature in both our books; specifically in Sam's Teach Yourself Android Application Development in 24 Hours
Unfortunately, a recent update to the Android Development Tools plugin removed this drop-down. We're not sure if it's a bug or not yet, but the drop-down disappeared in the software update between ADT 0.9.8 or ADT 0.9.9.
What used to look like:
![]() |
| Permissions tab from ADT 0.9.7 showing the drop-down list of values |
![]() |
| Permissions tab from ADT 0.9.9, with the corresponding Browse... dialog |
The field provided still works for typing in permissions values by hand, instead of selecting them from a list. The alternate method, editing the XML file directly from the last tab, hasn't changed at all.
So where is one to get these values to type in yourself? On page 90 and 91 of the SAMS book, we've listed a number of the most common permission values. However, the best place to get the appropriate values for your applications is from the Android SDK documentation. Permissions are defined in the documentation for the android.Manifest.permission class. Also conveniently listed with these values is a short description of what they enable the application to do. Before including a permission within your application, always check the documentation to determine if that is the most appropriate one to use.
Jumat, 17 September 2010
Building an Android Application: Book Excerpt
Sometimes publishers allow sites to publish entire chapters of books. ComputerWorld recently published a complete chapter from Sam's Teach Yourself Android Application Development in 24 Hours
. We think this is a particularly good excerpt, too, as it has broad topic coverage.
This excerpt, from Hour 3, covers topics from application design to resources to Android Activities. And then it goes on, and covering Activity lifecycle and even Intents and various things you can do with them as a developer. You even get information about debug logging. It's not just a preview of Hour 3, it's nearly the whole chapter.
Check it out at ComputerWorld!
This excerpt, from Hour 3, covers topics from application design to resources to Android Activities. And then it goes on, and covering Activity lifecycle and even Intents and various things you can do with them as a developer. You even get information about debug logging. It's not just a preview of Hour 3, it's nearly the whole chapter.
Check it out at ComputerWorld!
Selasa, 10 Agustus 2010
Reader Feedback: On Log Tags
![]() |
| Sam's Teach Yourself Android Application Development in 24 Hours |
Log.d(DEBUG_TAG, "SHARED_PREFERENCES");
// (From Hour 10, Page 177)
A couple of readers have asked us: What is DEBUG_TAG? Where is it defined?
The short answer is: you need to define it! By this point in the book, we aren't displaying every line of code you need for the application to compile--only the relevant new code for that particular lesson. We assume that you've mastered certain fundamental Android skills in the previous chapters of the book. One of these skills is understanding the Log calls, such as Log.v or Log.d. which were discussed in detail in Hour 3, Page 54. This skill is essential for debugging Android applications and is used regularly throughout the book.
Log method calls simply display diagnostic information to the Logcat logging tool, providing the developer with important information as the application executes. These calls have no impact on the actual application functionality. The calls just log string output for debugging purposes. You can include these logging calls in your applications or simply leave them out (and not provide diagnostic logging). If you want to log information using the logging calls, you will need to supply a tag string as the first parameter for each Log method. In Hour 3, we suggest that you define a logging tag for each and every Android project or class you create.
The logging tag is shown in the log output of logcat, so you can tell that the information is coming from your application, Activity, class, or method. It's that simple.
![]() |
| LogCat output showing all device logs. Cluttered. |
You can also filter on just the tag, which shows the real power of it.
![]() |
| LogCat, with filter to show only the tag "GestureFunActivity" |
So, when you run across a line in the book that uses such a call, we do not provide the definition of DEBUG_TAG variable. Instead, we assume you know that this is a generic logging call, and you should supply the definition of the variable somewhere in your class. For example, if you want to add logging calls to an Activity class called QuizHelpActivity, class, you should add a definition such as:
Or maybe you'd prefer:private static final String DEBUG_TAG = "QuizHelpActivity";
Or even something for your entire application:private static final String DEBUG_TAG = "QuizHelpActivity Logging Info: ";
private static final String DEBUG_TAG = "MyAppLogging";Those of you who have Java experience will likely recognize that the DEBUG_TAG variable is a constant. That is to say, it has the static final qualifiers. Since the input type to the Log functions are String objects, you then know this to be a static final String. Remember that the logging tag should be descriptive for the specific application or class. In fact, it's often set to the class name, but there is no requirement to do so.
We hope this helps clear up this question. As always, feel free to email us or post a comment right here!
Langganan:
Postingan (Atom)
Category
- 1.5 (2)
- 1.5 1.5 R1 (2)
- 1.6r2 (1)
- 2.0 (3)
- 2.0.1 (1)
- 4.0 (2)
- activity (1)
- activitymanager (1)
- address (1)
- amazon (2)
- android (54)
- android 3.0 (1)
- android 3.2 (1)
- android compatibility (2)
- android ndk (1)
- android sdk (2)
- Android Virtual Device (3)
- API (1)
- App (3)
- App Store (2)
- app widget (1)
- apple (1)
- appwidget (1)
- archos (2)
- article (1)
- articles (1)
- atrix (1)
- atrix4g (1)
- AVD (3)
- awad (2)
- awad2e (2)
- beginner (1)
- Berlin (1)
- blackberry (3)
- book (13)
- books (2)
- borders (1)
- brick (1)
- bug (3)
- bugs (1)
- business (5)
- business case (1)
- business plans (3)
- buzz (1)
- camangi (1)
- cell phone (3)
- class (1)
- code (8)
- code name (1)
- coding (2)
- college (1)
- commercial (1)
- compatibility (1)
- compatibility scaling (1)
- compiling (1)
- conference (1)
- contacts (1)
- contactscontract (1)
- coupon (1)
- coursework (1)
- cupcake (2)
- cute (1)
- DEBUG_TAG (1)
- debugging (1)
- defect tracking (3)
- defects (1)
- design (1)
- designer (1)
- developer (8)
- development (15)
- device (1)
- devices (2)
- diagnostics (1)
- discounts (1)
- distribution (1)
- donut (1)
- download (1)
- droidcon (2)
- e-book (2)
- e-version (1)
- eclair (1)
- Eclipse (6)
- ed (1)
- edu (1)
- emulator (2)
- errata (2)
- error (2)
- errors (2)
- europe (1)
- excerpt (1)
- exercise (1)
- extension (1)
- feedback (1)
- fix (1)
- fragmentation (1)
- free (3)
- froyo (1)
- fruit (1)
- fun (1)
- Germany (1)
- gingerbread (4)
- giveaway (2)
- Google (7)
- hardware (3)
- help (1)
- higher education (1)
- holiday (1)
- Home screen (1)
- honeycomb (2)
- host (1)
- ice cream sandwich (2)
- ics (2)
- IDE (1)
- implementation (1)
- incentive (1)
- informit (1)
- installation (1)
- internationalization (1)
- iPhone (4)
- issue (1)
- Junit (1)
- korea (2)
- korean (1)
- L14 (1)
- language (1)
- layout (2)
- layout editor (1)
- learning (2)
- level 13 (1)
- local (1)
- locale (1)
- localization (1)
- logging (2)
- mac (2)
- macos (1)
- manifest (1)
- maps (1)
- marketplace (5)
- mobile (13)
- mobile platform (5)
- mobiletuts+ (1)
- moblie (1)
- monetization (1)
- motorola (1)
- news (1)
- paid (1)
- parse (1)
- plug-in (2)
- plugin (1)
- preview (3)
- project risk (2)
- provider (1)
- published (3)
- publishing (2)
- purchase (3)
- QA (1)
- quality assurance (1)
- question (1)
- raw (1)
- raw resources (1)
- reading (3)
- release (1)
- resources (1)
- review (1)
- revisions (1)
- root (1)
- safari (1)
- sale (1)
- sample (2)
- samples (1)
- SAMS (7)
- sams2e (2)
- scaling (1)
- SDK (7)
- SDK update (3)
- server (1)
- slides (1)
- snapshot (1)
- Software (3)
- source code (3)
- source control (2)
- student (1)
- sty (1)
- subscription (1)
- tablet (1)
- tablets (1)
- tale (1)
- teacher (1)
- teaching (3)
- testing (3)
- tips (4)
- tools (2)
- translation (1)
- travel (1)
- tricks (1)
- tutorial (5)
- unit testing (1)
- update (2)
- updates (2)
- upgrade (5)
- URI (1)
- version (4)
- video (2)
- VideoView (1)
- widget (1)
- wireless (14)
- workaround (1)





