100% found this document useful (2 votes)
15 views

(Ebook) Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition by Jonathan Stark, Brian Jepson ISBN 9781449316419, 1449316417 - Download the full ebook set with all chapters in PDF format

The document provides information on downloading various ebooks, including 'Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition' by Jonathan Stark and Brian Jepson. It includes links to additional recommended ebooks and details about the book's content, structure, and intended audience. The book aims to guide developers in creating mobile applications using web technologies, emphasizing the flexibility and reach of HTML, CSS, and JavaScript.

Uploaded by

chitopshahr
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
15 views

(Ebook) Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition by Jonathan Stark, Brian Jepson ISBN 9781449316419, 1449316417 - Download the full ebook set with all chapters in PDF format

The document provides information on downloading various ebooks, including 'Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition' by Jonathan Stark and Brian Jepson. It includes links to additional recommended ebooks and details about the book's content, structure, and intended audience. The book aims to guide developers in creating mobile applications using web technologies, emphasizing the flexibility and reach of HTML, CSS, and JavaScript.

Uploaded by

chitopshahr
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Visit ebooknice.

com to download the full version and


explore more ebooks or textbooks

(Ebook) Building Android Apps with HTML, CSS, and


JavaScript, 2nd Edition by Jonathan Stark, Brian
Jepson ISBN 9781449316419, 1449316417

_____ Click the link below to download _____


https://ebooknice.com/product/building-android-apps-with-
html-css-and-javascript-2nd-edition-2510768

Explore and download more ebooks or textbooks at ebooknice.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

(Ebook) Biota Grow 2C gather 2C cook by Loucas, Jason; Viles, James


ISBN 9781459699816, 9781743365571, 9781925268492, 1459699815,
1743365578, 1925268497

https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374

(Ebook) Building Android Apps with HTML, CSS, and JavaScript by


Jonathan Stark ISBN 9781449383268, 1449383262

https://ebooknice.com/product/building-android-apps-with-html-css-and-
javascript-1537242

(Ebook) Matematik 5000+ Kurs 2c Lärobok by Lena Alfredsson, Hans


Heikne, Sanna Bodemyr ISBN 9789127456600, 9127456609

https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312

(Ebook) SAT II Success MATH 1C and 2C 2002 (Peterson's SAT II Success)


by Peterson's ISBN 9780768906677, 0768906679

https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
(Ebook) Cambridge IGCSE and O Level History Workbook 2C - Depth Study:
the United States, 1919-41 2nd Edition by Benjamin Harrison ISBN
9781398375147, 9781398375048, 1398375144, 1398375047

https://ebooknice.com/product/cambridge-igcse-and-o-level-history-
workbook-2c-depth-study-the-united-states-1919-41-2nd-edition-53538044

(Ebook) Master SAT II Math 1c and 2c 4th ed (Arco Master the SAT
Subject Test: Math Levels 1 & 2) by Arco ISBN 9780768923049,
0768923042

https://ebooknice.com/product/master-sat-ii-math-1c-and-2c-4th-ed-
arco-master-the-sat-subject-test-math-levels-1-2-2326094

(Ebook) Building iPhone Apps with HTML, CSS, and JavaScript: Making
App Store Apps Without Objective-C or Cocoa by Jonathan Stark ISBN
9780596805784, 0596805780

https://ebooknice.com/product/building-iphone-apps-with-html-css-and-
javascript-making-app-store-apps-without-objective-c-or-cocoa-1467236

(Ebook) Building iphone apps with html, css, and javascript: Making
App Store Apps Without Objective-C or Cocoa by Stark, Jonathan ISBN
9780596805784, 9781449382919, 9781449389000, 0596805780, 1449382916,
1449389007
https://ebooknice.com/product/building-iphone-apps-with-html-css-and-
javascript-making-app-store-apps-without-objective-c-or-cocoa-18480948

(Ebook) Programming Windows Store Apps with HTML, CSS, and JavaScript
by Kraig Brockschmidt

https://ebooknice.com/product/programming-windows-store-apps-with-
html-css-and-javascript-11697606
SECOND EDITION

Building Android Apps with


HTML, CSS, and JavaScript

Jonathan Stark
with Brian Jepson

Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo


Building Android Apps with HTML, CSS, and JavaScript, Second Edition
by Jonathan Stark with Brian Jepson

Copyright © 2012 Jonathan Stark. All rights reserved.


Printed in the United States of America.

Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.

O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.

Editor: Brian Jepson Cover Designer: Karen Montgomery


Production Editor: Kristen Borg Interior Designer: David Futato
Proofreader: O’Reilly Production Services Illustrator: Robert Romano

September 2010: First Edition.


January 2012: Second Edition.

Revision History for the Second Edition:


2012-01-10 First release
See http://oreilly.com/catalog/errata.csp?isbn=9781449316419 for release details.

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Building Android Apps with HTML, CSS, and JavaScript, the image of a maleo, and
related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.

ISBN: 978-1-449-31641-9

[LSI]

1326207514
To Erica & Cooper
Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

1. Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Web Apps Versus Native Apps 1
What Is a Web App? 1
What Is a Native App? 1
Pros and Cons 2
Which Approach Is Right for You? 2
Web Programming Crash Course 3
Introduction to HTML 3
Introduction to CSS 6
Introduction to JavaScript 9

2. Basic Styling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Don’t Have a Website? 13
First Steps 15
Prepare a Separate Android Stylesheet 19
Control the Page Scaling 20
Adding the Android CSS 22
Adding the Android Look and Feel 26
Adding Basic Behavior with jQuery 28
What You’ve Learned 33

3. Advanced Styling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Adding a Touch of Ajax 35
Traffic Cop 36
Setting Up Some Content to Work With 38
Routing Requests with JavaScript 39
Simple Bells and Whistles 41
Progress Indicator 41
Setting the Page Title 44

v
Handling Long Titles 46
Automatic Scroll-to-Top 47
Hijacking Local Links Only 49
Roll Your Own Back Button 49
Adding an Icon to the Home Screen 56
What You’ve Learned 57

4. Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
With a Little Help from Our Friend 59
Sliding Home 59
Adding the Dates Panel 62
Adding the Date Panel 65
Adding the New Entry Panel 68
Adding the Settings Panel 70
Putting It All Together 74
Customizing jQTouch 76
What You’ve Learned 78

5. Client-Side Data Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79


Web Storage 79
Saving User Settings to Local Storage 80
Saving the Selected Date to Session Storage 84
Web SQL Database 85
Creating a Database 86
Inserting Rows 90
Selecting Rows and Handling Result Sets 93
Deleting Rows 97
Web Database Error Code Reference 101
What You’ve Learned 102

6. Going Offline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103


The Basics of the Offline Application Cache 103
Online Whitelist and Fallback Options 107
Creating a Dynamic Manifest File 113
Debugging 117
The JavaScript Console 118
What You’ve Learned 120

7. Going Native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121


Introduction to PhoneGap 121
Building Your App Locally with Eclipse and the Android SDK 122
Download and Install Eclipse Classic 122
Download and Install the Android SDK 123

vi | Table of Contents
Install the ADT Plug-In in Eclipse 123
Add Android Platforms and Other Components 124
Download the Latest Copy of PhoneGap 125
Set Up a New Android Project 125
Running Kilo as an Android App 127
Controlling the Phone with JavaScript 129
Beep, Vibrate, and Alert 129
Geolocation 133
Accelerometer 140
What You’ve Learned 143

8. Submitting Your App to the Android Market . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145


Preparing a Release Version of Your App 145
Removing Debug Code 145
Versioning Your App 146
Compile and Sign Your App 147
Uploading Your App to the Android Market 147
Distributing Your App Directly 149
Further Reading 153

Appendix: Detecting Browsers with WURFL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

Table of Contents | vii


Preface

Thanks to mobile phones, we have moved from virtually no one having access to in-
formation to virtually everyone having access to the vast resources of the Web. This is
arguably the most important achievement of our generation. Despite its overarching
importance, mobile computing is in its infancy. Technical, financial, and political forces
have created platform fragmentation like never before, and it’s going to get worse before
it gets better.
Developers who need to engage large and diverse groups of people are faced with a
seemingly impossible challenge: “How do we implement our mobile vision in a way
that is feasible, affordable, and reaches the greatest number of participants?” In many
cases, the answer is web technologies. The combination of advances in HTML5 and
mobile devices has created an environment in which even novice developers can build
mobile apps that improve people’s lives on a global scale.
Google’s Android operating system is a compelling addition to the mobile computing
space. In true Google fashion, the platform is open, free, and highly interoperable. The
development tools are full-featured and powerful, if a bit geeky, and run on a variety
of platforms.
Carriers and handset manufacturers have jumped on the Android bandwagon. The
market is beginning to flood with Android devices of all shapes and sizes. This is a
double-edged sword for developers. On one hand, more devices mean a bigger market.
On the other hand, more devices mean more fragmentation. As with the fragmentation
in the general mobile market, fragmentation on Android can often be addressed by
building apps with HTML, CSS, and JavaScript.
I’m the first to admit that not all apps are a good fit for development with web tech-
nologies. That said, I see a lot of apps written with native code that could have just as
easily been done with HTML. When speaking to developers who aren’t sure which
approach to take, I say this:
If you can build your app with HTML, CSS, and JavaScript, you probably should.

ix
Using open source, standards-based web technologies gives you the greatest flexibility,
the broadest reach, and the lowest cost. You can easily release it as a web app, then
debug and test it under load with thousands of real users. Once you are ready to rock,
you can use PhoneGap to convert your web app to a native Android app, add a few
device-specific features if you like, and submit to the Android Market—or offer it for
download from your website. Sounds good, right?

Who Should Read This Book


I’m going to assume you have some basic experience reading and writing HTML, CSS,
and JavaScript (jQuery in particular). Chapter 5 includes some basic SQL code, so a
passing familiarity with SQL syntax would be helpful but is not required.

What You Need to Use This Book


This book avoids the Android SDK wherever possible. All you need to follow along
with the vast majority of examples is a text editor and the most recent version of Google
Chrome (a cutting-edge web browser that’s available for both Mac and Windows at
http://www.google.com/chrome). You do need to have the Android SDK for the Phone-
Gap material in Chapter 7, where I explain how to convert your web app into a native
app that you can submit to the Android Market.

Conventions Used in This Book


The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements
such as variable or function names, databases, data types, environment variables,
statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter-
mined by context.

This icon signifies a tip, suggestion, or general note.

x | Preface
This icon indicates a warning or caution.

Using Code Examples


This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “Building Android Apps with HTML,
CSS, and JavaScript, 2nd edition by Jonathan Stark (O’Reilly). Copyright 2012 Jonathan
Stark, 978-1-4493-1641-9.”
If you feel your use of code examples falls outside fair use or the permission given above,
feel free to contact us at permissions@oreilly.com.

Safari® Books Online


Safari Books Online is an on-demand digital library that lets you easily
search over 7,500 technology and creative reference books and videos to
find the answers you need quickly.
With a subscription, you can read any page and watch any video from our library online.
Read books on your cell phone and mobile devices. Access new titles before they are
available for print, and get exclusive access to manuscripts in development and post
feedback for the authors. Copy and paste code samples, organize your favorites, down-
load chapters, bookmark key sections, create notes, print out pages, and benefit from
tons of other time-saving features.
O’Reilly Media has uploaded this book to the Safari Books Online service. To have full
digital access to this book and others on similar topics from O’Reilly and other pub-
lishers, sign up for free at http://my.safaribooksonline.com.

Preface | xi
How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at:
http://shop.oreilly.com/product/0636920022886.do
To comment or ask technical questions about this book, send email to:
bookquestions@oreilly.com
For more information about our books, conferences, Resource Centers, and the
O’Reilly Network, see our website at:
http://www.oreilly.com

Acknowledgments
Writing a book is a team effort. My heartfelt thanks go out to the following people for
their generous contributions.
Tim O’Reilly, Brian Jepson, and the rest of the gang at ORM for making the experience
of writing this book so rewarding and educational.
David Kaneda for his wonderfully obsessive pursuit of beauty. Whether it’s a bit of
code or a user interface animation, he can’t sleep until it’s perfect, and I love that.
The gang at Nitobi for creating and continuing to support PhoneGap.
Brian Fling for broadening my view of mobile beyond just the latest and greatest hard-
ware. Brian knows mobile from back in the day; he’s a wonderful writer, and on top
of that, a very generous guy.
PPK, John Gruber, John Allsopp, and John Resig for their contributions to and support
of the underlying technologies that made this book possible.
Joe Bowser, Brian LeRoux, Sara Czyzewicz, and the swarm of folks who generously
posted comments and questions on the OFPS site for this book. Your feedback was
very helpful and much appreciated.
My wonderful family, friends, and clients for being understanding and supportive while
I was chained to the keyboard.

xii | Preface
And finally, Erica. You make everything possible. I love you!

Preface | xiii
CHAPTER 1
Getting Started

Before we dive in, I’d like to quickly establish the playing field. In this chapter, I’ll define
key terms, compare the pros and cons of the two most common development ap-
proaches, and give a crash course on the three core web technologies used in this book.

Web Apps Versus Native Apps


First, I’d like to define what I mean by web app and native app and consider their pros
and cons.

What Is a Web App?


To me, a web app is basically a website that is specifically optimized for use on a
smartphone. The site content can be anything from a standard small business brochure
site to a mortgage calculator to a daily calorie tracker—the content is irrelevant. The
defining characteristics of a web app are that the user interface (UI) is built with web
standard technologies, it is available at a URL (public, private, or perhaps behind a
login), and it is optimized for the characteristics of a mobile device. A web app is not
installed on the phone, it is not available in the Android Market, and it is not written
with Java.

What Is a Native App?


In contrast, native apps are installed on the Android phone, they have access to the
hardware (speakers, accelerometer, camera, etc.), and they are written with Java. The
defining characteristic of a native app, however, is that it’s available in the Android
Market—a feature that has captured the imagination of a horde of software entrepre-
neurs worldwide, myself included.

1
Pros and Cons
Different applications have different requirements. Some apps are a better fit with web
technologies than others. Knowing the pros and cons of each approach will help you
make a better decision about which path is appropriate for your situation.
Here are the pros of native app development:
• Millions of registered credit card owners are one click away
• You can access all the cool hardware features of the device
Here are the cons of native app development:
• You have to pay to become an Android developer
• Your app will run only on Android phones
• You have to develop using Java
• The development cycle is slow (develop, compile, deploy, repeat)
Here are the pros of web app development:
• Web developers can use their current authoring tools
• You can use your current web design and development skills
• Your app will run on any device that has a web browser
• You can fix bugs in real time
• The development cycle is fast
Here are the cons of web app development:
• You cannot access the all cool hardware features of the phone
• You have to roll your own payment system if you want to charge for the app
• It can be difficult to achieve sophisticated UI effects

Which Approach Is Right for You?


Here’s where it gets exciting. The always-online nature of the Android phone creates
an environment in which the lines between a web app and a native app get blurry. There
are even some little-known features of the Android web browser (see Chapter 6) that
allow you to take a web app offline if you want. What’s more, several third-party
projects—of which PhoneGap is the most notable—are actively developing solutions
that allow web developers to take a web app and package it as a native app for Android
and other mobile platforms.

2 | Chapter 1: Getting Started


For me, this is the perfect blend. I can write in my preferred language, release a product
as a pure web app (for Android and any other devices that have a modern browser),
and use the same code base to create an enhanced native version that can access the
device hardware and potentially be sold in the Android Market. This is a great way to
create a “freemium” model for your app—allow free access to the web app and charge
for the more feature-rich native version.

Web Programming Crash Course


The three main technologies we will use to build web apps are HTML, CSS, and Java-
Script. We’ll quickly cover each to make sure we’re all on the same page before plowing
into the fancy stuff.

Introduction to HTML
When you are browsing the web, the pages you are viewing are just text documents
sitting on someone else’s computer. The text in a typical web page is wrapped in HTML
tags, which tell your browser about the structure of the document. With this informa-
tion, the browser can decide how to display the information in a way that makes sense.
Consider the web page snippet shown in Example 1-1. On the first line, the string
Hi there! is wrapped in a pair of h1 tags. Notice that the open tag and the close tag are
slightly different: the close tag has a slash (/) as the second character, while the open
tag does not have a slash.
Wrapping text in h1 tags tells the browser that the words enclosed are a heading, which
will cause it to be displayed in large bold text on its own line. There are also h2, h3, h4,
h5, and h6 heading tags. The lower the number, the more important the header, so text
wrapped in an h6 tag will be smaller (i.e., less important-looking) than text wrapped in
an h3 tag.
After the h1 tag in Example 1-1, there are two lines wrapped in p tags. These are called
paragraph tags. Browsers will display each paragraph on its own line. If the paragraph
is long enough to exceed the width of the browser window, the text will bump down
and continue on the next line. In either case, a blank line will be inserted after the
paragraph to separate it from the next item on the page.
Example 1-1. HTML snippet
<h1>Hi there!</h1>
<p>Thanks for visiting my web page.</p>
<p>I hope you like it.</p>

You can also put HTML tags inside other HTML tags. Example 1-2 shows an unordered
list (ul) tag that contains three list items (li). In a browser, this appears as a bulleted
list with each item on its own line. When you have a tag or tags inside another tag, the

Web Programming Crash Course | 3


inner tags are called child elements, or children, of the parent tag. So in this example,
the li tags are children of the ul parent.
Example 1-2. Unordered list
<ul>
<li>Pizza</li>
<li>Beer</li>
<li>Dogs</li>
</ul>

The tags covered so far are all block tags. The defining characteristic of block tags is
that they are displayed on a line of their own, with no elements to the left or right of
them. That is why the heading, paragraphs, and list items progress down the page
instead of across it. The opposite of a block tag is an inline tag, which, as the name
implies, can appear in a line. The emphasis tag (em) is an example of an inline tag, and
it looks like this:
<p>I <em>really</em> hope you like it.</p>

The granddaddy of the inline tags—and arguably the coolest feature of HTML—is the
a tag. The “a” stands for anchor, but at times I’ll also refer to it as a link or hyperlink.
Text wrapped in an anchor tag is clickable, such that clicking on it causes the browser
to load a new HTML page.
To tell the browser which new page to load, we have to add what’s called an at-
tribute to the tag. Attributes are named values that you insert into an open tag. In an
anchor tag, you use the href attribute to specify the location of the target page. Here’s
a link to Google’s home page:
<a href="http://www.google.com/">Google</a>

That might look like a bit of a jumble if you are not used to reading HTML, but you
should be able to pick out the URL for the Google home page. You’ll be seeing a lot of
a tags and href attributes throughout the book, so take a minute to get your head around
this if it doesn’t make sense at first glance.

There are a couple of things to keep in mind regarding attributes. Dif-


ferent HTML tags allow different attributes. You can add multiple
attributes to an open tag by separating them with spaces. You never add
attributes to a closing tag. There are hundreds of possible combinations
of attributes and tags, but don’t sweat it—we only have to worry about
a dozen or so in this entire book.

The HTML snippet that we’ve been looking at would normally reside in the body section
of a complete HTML document. An HTML document is made up of two sections: the
head and the body. The body is where you put all the content that you want users to
see. The head contains information about the page, most of which is invisible to the
user.

4 | Chapter 1: Getting Started


Random documents with unrelated
content Scribd suggests to you:
The Project Gutenberg eBook of
The Boy Scouts at the Canadian
Border
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: The Boy Scouts at the Canadian Border

Author: John Henry Goldfrap

Release date: December 4, 2015 [eBook #50602]


Most recently updated: October 22, 2024

Language: English

Credits: Produced by Stephen Hutcheson, Dave Morgan and the


Online
Distributed Proofreading Team at http://www.pgdp.net

*** START OF THE PROJECT GUTENBERG EBOOK THE BOY SCOUTS


AT THE CANADIAN BORDER ***
THE BOY SCOUTS
AT THE CANADIAN BORDER

By LIEUT. HOWARD PAYSON

Author of
“The Boy Scouts of the Eagle Patrol,” “The Boy Scouts
on the Range,” “The Boy Scouts’ Mountain Camp,” “The
Boy Scouts for Uncle Sam,” “The Boy Scouts at the
Panama Canal,” “The Boy Scouts and the Army Airship,”
“The Boy Scouts with the Allies in France,” “The Boy
Scouts on Belgian Battlefields,” “The Boy Scouts Under
Fire in Mexico,” “The Boy Scouts at the Panama-Pacific
Exposition,” “The Boy Scouts’ Campaign for
Preparedness,” “The Boy Scouts Under Sealed Orders,”
“The Boy Scouts’ Badge of Courage,” etc.
A. L. BURT COMPANY
Publishers New York
Printed in U. S. A.

Copyright, 1918, by
Hurst & Co., Inc.
Printed in U. S. A.
CONTENTS

CHAPTER PAGE
I. A Glimpse over into Canada 5
II. Rumblings of Coming Trouble 19
III. By Aeroplane Across the Border 30
IV. An Invasion of the Camp 42
V. Comforting Tubby 54
VI. The Logging Camp 66
VII. An Unwelcome Intruder 78
VIII. Tubby Has an Adventure 91
IX. The Man Outside 104
X. Neatly Done 114
XI. Zeb Makes Good 129
XII. A Scout’s First Duty 142
XIII. A Thrilling Discovery 154
XIV. Rob Makes Up His Mind 166
XV. On Duty Bent 178
XVI. The Stone Cairn on the Border 190
XVII. Lynx Law 202
XVIII. The Trail to the Trestle 214
XIX. The Hunt for the Wire 226
XX. The Munition Train’s Approach 238
XXI. Cutting the Battery Connections 250
XXII. Like Old Times for the Scouts 260
XXIII. In Swift Pursuit 272
XXIV. Those Who Sat by the Fire 284
XXV. Bad Luck, and Good 296
XXVI. Everybody Satisfied 308

The Boy Scouts at the


Canadian Border
CHAPTER I
A GLIMPSE OVER INTO CANADA

“Suppose we hold up here, and rest a bit, fellows!”

“We’ll have to accommodate you, Tubby. It really pains


me to hear you puffing and blowing so hard.”

“Now, that’s just six words for me and half a dozen for
yourself, Andy Bowles. Haven’t I seen you look longingly
at every log we passed, as if you wished Rob would give
the order to sit down and recuperate? Honest to
goodness, I do own up that I’m a trifle winded. This
pack seems to keep on getting heavier and heavier.”

“You only imagine it does, Tubby, that’s all. If a fellow is 6


shaped like a wash-tub, what else could you expect of
him when it comes to toting a load of duffle and grub
over a Maine carry?”

“And when another angular chap I know is said to


resemble a broom-handle, so far as symmetry and
plumpness goes, you’ve got to expect that his greatest
feats are accomplished when grub is served. That’s a
time, Andy Bowles, bugler of the Hampton Troop of Boy
Scouts, when you make competition throw up its hands
in despair and retire from the field; your capacity in that
line is without a peer.”
“That’s right, Tubby, take a swig of water from your
battered old canteen after such a spread-eagle speech.
I’m sure your throat must be parched, and as dry as a
bone.”

“Here, fellows, suppose you let up badgering each


other; and after we drop down on this log in the little
open glade, what’s to hinder us from figuring out our
next move in the search for Tubby’s Uncle George?”

The energetic speaker was Rob Blake. Those fortunate 7


boys who have read any or all of the preceding volumes
in this Series, do not need to be introduced to so
prominent a character of the stories; but, of course,
there will be many who are making the acquaintance of
these wearers of khaki for the first time, and in justice
to them it is only fair that we offer a few explanations
while the trio stretch themselves upon that friendly pine
log.

They all belonged to the famous Eagle Patrol of the


Hampton Troop of Boy Scouts, Hampton being a Long
Island town on the south shore. In times gone by many
were the interesting happenings that came the way of
some of the fellows belonging to that patrol. To even
enumerate them here would take too long a time, and
hence he who is desirous of knowing more about Rob
Blake and his chums is referred to earlier volumes,
where thrilling and uplifting scenes are depicted in a
most entertaining fashion.

Some of these boys had visited the Panama Canal; had 8


even gone abroad and been in a position to witness
stirring action in the great war theater of Europe; spent
delightful days wandering about the grounds of the
wonderful Panama-Pacific Exposition out in California;
chased over the torrid deserts of Mexico, when the
revolutionist, Pancho Villa, was pursuing his earlier
meteor-like career on bloody battlefields; and later still
they had been connected with the amazing wave of
preparedness that swept over our country from shore to
[1]
shore.

What brought the three lads far up toward the


international border at this season of the fall can be
easily explained. As the reader has already learned by
reason of the words which Rob Blake uttered when
suggesting that they rest from their labors, it had
something to do with a relative of fat Tubby Hopkins.

“Uncle George” was a well-to-do gentleman, and a great 9


sportsman. Every autumn he would slip away from
business cares and spend a month with a couple of
faithful woods guides hunting in the solitudes.
Sometimes he went into the “bush” far up in the
Canadian wilds after bull moose; or it might be seeking
caribou in Labrador. This season it was not so pleasant
to be within the boundaries of Canada, owing to the
distracted conditions prevailing there, with young
fellows enlisting for service abroad, and hundreds of
men of German parentage and sympathies held in
concentration camps; so Uncle George had wisely
chosen to confine his hunting to the most inaccessible
region in Maine.

Now it chanced that there had been some sort of


epidemic in many Long Island communities that
summer, and at certain points it held out so long in the
fall that the school authorities became alarmed. At
Hampton, sessions had been taken up only to be
hurriedly discontinued, nor was school to be resumed
for a period of at least two weeks.

That gave many of the boys a chance to lay plans for 10


delightful outings. As a rule, the fall was a closed
season to them, Saturday being their only off-day; and
usually they had to put in most of that weekly holiday
practicing for their football games to be played later.

Just at the time this occurred, Tubby Hopkins came to


Rob and announced that an opportunity had arisen
whereby he and two companions could take a flying trip
up into Maine at no cost to themselves, as his father
was ready to put up every dollar of the expense.

It seemed that a very important document should be


signed by Uncle George within two weeks, or he and Mr.
Hopkins stood to lose a large amount of money. Since
the devoted sportsman did not plan to be seen in the
realm of civilization under a whole month, and could not
be reached by wire or letter, it became absolutely
necessary that some messenger find his camp, and
bring back the document signed.

Tubby asked Rob to engineer the expedition, for he had


the utmost faith in the ability of the acting scout master
of the troop. As several other fellows had already made
arrangements for the new vacation, it happened that
Andy Bowles was invited to make the third of the party.

Now, while Tubby and Andy often “scrapped” so far as a 11


verbal exchange of pleasantries was concerned, they
really were exceedingly fond of each other; and so the
little party promised to get along very nicely together.

They had made the journey by railroad, leaving the cars


at a certain small station, and, taking their packs on
their backs, starting out on the strength of the rather
uncertain schedule of his expected movements, which
Uncle George had left behind at his city house when
heading toward the Maine wilderness.

If they did not find him at a certain logging camp, at


least they were likely to pick up a clue there as to where
he had gone, and thus could follow after him. Rob had
intended finding a competent guide, but it chanced that
there was an unusually heavy demand for experienced
woodsmen that season, and they met with several
disappointments, until finally the others had urged Rob
to make the plunge himself unattended.

They knew that he could be depended on to lead them 12


safely, for Rob had considerable experience in
woodcraft, and, besides this, carried a reliable chart of
the region they were traversing.

Accordingly they had set forth valiantly, and at the time


we meet them had been tramping for two days.
According to Rob’s figuring, they must be getting close
to the logging camp where, possibly, they would find
Uncle George; at the same time he also knew that they
were near the International Boundary.

“If you take a look over that way, due north, fellows,”
Rob was telling the other boys, as they sat there on the
log, and pointing as he spoke, “you can see for several
miles. Notice that big clump of hemlocks on the rise
yonder, along the near horizon? Well, unless I miss my
guess, that’s Canada!”

“But I don’t see the line, Rob,” observed Tubby vaguely.

At this remark Andy Bowles burst forth in a laugh. 13


“Why, listen to the innocent, will you, Rob! Honest, now,
I believe Tubby thinks the International Boundary is a
real line drawn across the Divide from the Atlantic to the
Pacific, to mark the division of Uncle Sam’s property
from the Dominion of Canada and the Great Northwest
Territory!”

“Oh, shucks! Of course I was only joking,” stammered


the confused Tubby. “So that’s Canada, is it, Rob?
Almost any old place across the line we’d likely find that
conditions resembled Belgium and Northern France
somewhat, with young men drilling at every crossroads,
artillery companies rushing to stations to be sent across
the sea, cavalry horses being herded, cattle slaughtered
for meat to keep the army supplied, wheat trains
heading toward some Atlantic port to be shipped abroad
to feed those millions of fighters. Whee! It’s hard to
believe that peaceful country over there can be
Canada!”

“Oh, that’s only the border, Tubby, you see,” explained 14


Rob, always ready to accommodate. “Farther back I’ve
no doubt all those things are daily taking place, for you
know Canada has already sent over three hundred
thousand soldiers across the sea to fight for the Cause
of Civilization. You and I have been at the front, Tubby,
and we know the spirit that animates most of those
men among the Allies; also how they expect to stick to
their job, now they’ve begun, until it’s finished.”

“You mean, do you, Rob,” interrupted the listening Andy,


who had not had the same good fortune as the others
to see some of the fighting across in Belgium and
Northern France, “that even while the Dominion is being
shaken from east to west, right here along the border
it’s just as it always was?”
“Well, hardly that,” continued the other hastily. “You 15
know there have been all sorts of stories in the papers
about plots hatched and engineered in the States by
those whose sympathies are with Germany, and who
feel furious because of the never-ending trains loaded
with munitions, soldiers, food, aeroplane parts, motor
trucks, and such things that an army in the field would
require—these all heading across Canada, and aiming
for the ports where steamers are waiting to carry
cargoes to Great Britain. It would make these German
sympathizers joyous if only something might happen to
cut off this endless chain of supplies for the Allies.”

“Yes,” added Tubby eagerly. “I’ve read where the folks


down in Washington are dreadfully alarmed lest one of
these terrible schemes may succeed. You recall how the
President enjoined everybody in the States to be strictly
neutral, and not to lift a hand toward doing anything
that might be reckoned an unfriendly or unneighborly
act by the aroused people of Canada? So now the
Government on both sides is keeping an extra guard
along the border, in order to nip any such black scheme
in the bud.”

“I’ve been told that’s the case,” Rob assured them. The 16
talk went on along the same lines until finally the scout
master, jumping up, announced:

“Well, we’ve rested long enough, I guess! We’d better


put our best foot forward if we hope to get anywhere
near that logging camp close to the border. So pick up
your packs, fellows, and we’ll be off!”

“Oh, listen to that, would you!” cried Tubby excitedly. “It


sounded just like the far-away whistle of a railroad
locomotive.”
“A good guess, Tubby,” chuckled Andy, “because that’s
just what it was. I half expected you’d ask Rob if it
could be the scream of one of those Canadian lynx
we’ve heard tell about are to be found up here.”

They were conversing while walking, and once again the


whistle sounded. Even Tubby could tell now that it came
from the northwest. There was also a faint rumbling
sound that indicated the passage of a heavy train over a
trestle, miles away.

“Yes, the Great Canadian Railway runs close to the 17


boundary along here somewhere,” Rob said, “and I
suppose we’ll often hear distant whistles, for the traffic
at present must be unusually heavy. That’s likely a long
train filled with grain, and all sorts of valuable supplies
that are being sent from the rich Saskatchewan and
Alberta country, as an offering from the Canadian
Northwest granary. It means another nail in the coffin of
the Germans, when it reaches the land across the sea.
All day long, and night, too, at intervals, those trains are
running, carrying millions and millions of dollars’ worth
of supplies.”

“Huh!” chuckled Tubby, “if a German only chanced to


live around here, he’d have to stuff cotton in his ears to
shut out the sound; because each rumble of trains
would mean to him more trouble for his friends across
the sea.”

They pushed on for some time. Rob evidently had his 18


plan of campaign well figured out, for he now turned
sharply to the left and headed almost due west.
Apparently he fancied he was as near the International
Boundary as there might be any need of going; and that
the lone logging camp must lie farther along the new
course.

The startling idea had occurred to Tubby that, all


unbeknown to themselves, they might inadvertently
stray across the line, and be arrested as invaders, by
some of those alert Canadian guards mentioned by Rob.
The thought disturbed him considerably, and he was
about to speak of it, despite the jeers with which he felt
sure Andy would greet the idea, when something else
suddenly came to pass that completely put it out of his
head.

There was a crashing sound heard close by, a swishing


of the undergrowth, and then a bounding object flashed
into view, which took on the shape of a two-year-old
buck, leaping frantically over logs and bushes, as
though possessed. Upon his neck and shoulders the
boys glimpsed a strange, mysterious gray hunch!
Upon his shoulders the boys glimpsed a strange,
mysterious gray hunch.

19
CHAPTER II
RUMBLINGS OF COMING TROUBLE

“Oh! Did you see that hump on his back, Rob? What
could it have been?” gasped Tubby, gripping the sleeve
of the other’s khaki coat in his excitement.

“Why, Tubby, don’t you know that was the pirate of the
northern woods?” cried the equally aroused Andy, who
had also been stupefied while the little drama was being
enacted, and only recovered the use of his hands, and
realized that he was carrying a gun, when the leaping
buck had completely vanished from view.

“Do you mean a filibuster?” asked the stout boy


incredulously.

“Well, yes; you might call a panther by that name,”


laughed Rob.

“A panther!” echoed Tubby, thrilled more than ever. 20


“Was that what the bunch across the poor deer’s
shoulders was, Rob? Oh, to think we didn’t get a chance
to use a gun and save the noble buck!”

“It all happened too fast for me,” admitted Andy


dejectedly. “Besides, I don’t believe any of us could
have hit that crouching beast and not harmed the deer.”
“No, that’s right, Andy,” said Rob convincingly. “After all,
we only chanced to see one of the woods tragedies that
are taking place right along. Panthers must have meat
to live on, and deer are their legitimate prey. That’s why
there’s never a close season on the gray buccaneers,
nor on wildcats and wolves.”

Tubby did not express any timidity in words, but it might 21


have been noticed how he somehow managed to keep a
bit closer to his chums after that. If there were such
savage “varmints” at large in the country along the
International Boundary, Tubby did not think it wise to
take any unnecessary chances; not that he would have
admitted being afraid, of course; but then, as he always
said, he offered a shining mark, because a
discriminating beast was sure to pick out a plump
morsel when foraging for a dinner, and consequently
lucky Andy would get off scot-free.

They continued to walk on in a clump, and chatting as


they advanced, though Rob kept his eyes and senses
constantly on the alert for signs that would tell him
what he wished to know.

“I’ve heard a lot about the Maine woods, and how all
sorts of people manage to get a fair living from them,
winter or summer,” Tubby was saying later on. “Rob,
you know something of such things, because you’ve
been up here before. How about it?”

“It’s just as you say,” Rob replied. “Thousands on


thousands of men find ways to wring a living from
Nature’s storehouse up here in the great pine forests.
I’ve met some of them personally, and asked questions.
I’ve been told all about the others, and what interesting
stunts they do.”
“Tell us a little about them, please, Rob?” urged Tubby. 22

“Well,” began the scout leader, always willing to oblige


his chums when it was within his power to
accommodate, “first of all there are the thousands of
guides, both natives and Indians, who in summer take
parties along the waterways of Maine in canoes, fishing
for trout, bass, or salmon in the countless streams and
lakes; and in the fall serve the hunters in their camps,
when they are after deer and moose. They go to make
up quite a little army in themselves, and their wages
amount to many hundreds of thousands of dollars per
annum. Next in order and importance, I expect, is the
gum-hunter.”

“Well, I declare, what is a gum-hunter, anyway, Rob?”


demanded the listening Tubby. “I’ve heard of a
gumshoe man; but do hunters go shod that way in the
Maine woods?”

That allowed Andy, better posted, to have another little


explosion,

“Oh, dear innocent, trusting soul, you’ll be the death of 23


me yet!” he gasped, between his fits of laughter. “For
pity’s sake, Rob, tell him quickly what a gum-hunter is,
or he’ll surely burst with curiosity.”

“You must know, Tubby,” said Rob, himself smiling


broadly, “that spruce gum is used in immense
quantities, not only in the manufacture of chewing gum
but for several other purposes.

“It is found here in the pine woods of Maine by expert


searchers, who at a certain season of the year go forth
and gather their harvest. They probably make good
wages at their work, too, or there would not be so many
of them keeping at it year after year. Some other time
I’ll go further into details, and tell you how they find the
deposits of gum. Some of them even gash trees, and
come back in due season to garner the crystal profits
that have exuded from the wounds. But the gum-hunter
is only one of many chaps who earn a living in these
Maine forests. There is the hoop-hole man you’re apt to
run across in any section where it happens there’s a
second-growth crop of ash saplings.”

“What does he do, Rob?” asked Tubby. 24

“He gathers the saplings, and occupies his evenings in


camp by splitting and assorting and fastening them in
bundles. These are later taken away in bulk. They are
intended as hoops for barrels, nail-kegs, and such
objects. The hoop man does a cracking big business in
season, let me tell you.

“Then there’s the man who gets out the poles


themselves to be used for various purposes; the fellow
who hunts for certain crooked woods calculated to make
good boats’ knees; the sassafras hunter; the ginseng
and other root man, who knows where to pick up a little
fortune in discovering patches of wild weeds that
possess a marketable value when the roots are dug and
properly cured; the herb gatherer; and last but far from
least the bee man, who goes about looking for hives of
wild bees in hollow tree-tops, so he can gather
hundreds of pounds of honey.”

Tubby looked helplessly around him. 25

“Well, well,” he was heard to say, “you never would


believe fortunes could be dug out of such forlorn-
looking woods as these. It’s simply wonderful what
some men can pick up, when others are as blind as bats
in the daytime. I’m going to keep my eyes open. We
might run across a diamond field.”

“Well, you may mean that as a joke,” said Rob, “but rare
gems have been found around here, which brings up
another calling that some men have followed. That is
searching all the streams for mussels, because some
pretty valuable fresh-water pearls have been discovered,
they say, in Maine bivalves.”

“It beats all creation how many sources of revenue a 26


smart man can unearth, if only he keeps his wits about
him,” remarked Andy, who, apparently, was hearing this
last bit of information for the first time. “If this terrible
war continues much longer there’s likely to be another
lot of professionals working industriously up here in the
woods of Maine. They’ll be the friends of the Central
Empires, who want to give Old England and her
Colonies a backhanded blow by cutting off the supply of
munitions and supplies that keeps on flowing toward the
coast day after day.”

“Oh, why can’t the nations of the Old World keep the
peace like it’s been kept for a hundred years between
Uncle Sam and his big northern neighbor?” sighed the
tender-hearted Tubby sincerely. “Here’s a boundary of
over three thousand miles, and not a single fort to mark
the dividing line; whereas over across the water, look at
the enormous fortresses France and Belgium and
Germany have maintained, though none of the Belgians’
stood the awful pounding of those enormous guns
brought up by the Kaiser’s troops.”

“There’s a good reason for that, Tubby,” explained Rob. 27


“Americans and Canadians speak the same tongue, and
as a whole have the same aspirations. They understand
each other, you see. It’s different over in Europe, where
different nations hate like poison. We don’t seem to
meet with the same measure of success down along our
Mexican border, because those greasers never can
understand our motives, for we think along entirely
opposite lines.”

“When are we going to have a great World Peace, and


war be abolished?” begged Tubby, almost piteously.

“Search me!” said Andy. “Because I don’t believe such a


thing ever will be, as long as human nature is like it is;
though of course I’d be glad to see it brought about. If
the nations of the world could only form some sort of
practical union, like that of the States now, and so were
bound to keep the peace, it might be done. Happy the
man who has a hand in such a vast undertaking. If the
chance came to me to handle the steering wheel of
such a glorious job, why, I’d feel as lofty as—as that
hawk soaring right now away up there in the blue
heavens!”

Tubby mechanically followed the extended finger of the


speaker, and then uttered a sudden startled cry.

“Hawk!” he ejaculated derisively. “That shows your 28


ignorance, Andy. Hawk, do you say? Why, bless your
simple and confiding nature, don’t you know that object
away up near the fleecy white clouds, and heading due
north at this minute, is nothing more or less than an
aeroplane? Rob, am I right?”

Rob was himself staring upward, and he hastened to


reply:
“That’s just what it is, Tubby. After seeing so many of
those mosquitoes of the upper air currents soaring
above the hostile armies across the big pond, you are
able to tell one the minute you glimpse it. Yes, that’s an
aeroplane, as certain as that we are standing here
gaping up at it. I want you to notice that it’s heading
directly so as to cross the International Boundary line.”

“What does that mean, Rob?” questioned Andy


curiously, meanwhile continuing to crane his neck.

“Well, I’m only making a guess,” Rob ventured. “The 29


chances are that pilot up yonder may be connected with
some vile plot to destroy railroad property in the
Dominion of Canada, and is now bent on spying out the
land so as to make a chart of the country.”

30
CHAPTER III
BY AEROPLANE ACROSS THE BORDER

When the leader of the Eagle Patrol made this


astounding assertion both of his friends betrayed
additional interest. Indeed, it was a question whether
Andy or Tubby, by the rapt expression on their faces,
showed the greater excitement.

Tubby had one great advantage over his comrade. He


had been abroad with Rob and Merritt Crawford, and
had watched aeroplane pilots, both of the Allies and the
Germans, shooting like meteors across the skies, bent
on their work of learning what was going on back of the
enemy’s lines so as to give points to those who handled
the monster guns far in the rear, allowing them to drop
their shells exactly where most wanted.

“Well, to think of the nerve of that fellow!” exclaimed 31


the indignant Andy. “He snaps his fingers at the
proclamation of the President about all true Americans
standing for strict neutrality. Why, he’s meaning to give
those Canucks the best chance ever to protest and
claim damages from our Government. Isn’t that a fact,
Rob?”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebooknice.com

You might also like