Mark Murphy - Beginning Android

Здесь есть возможность читать онлайн «Mark Murphy - Beginning Android» весь текст электронной книги совершенно бесплатно (целиком полную версию без сокращений). В некоторых случаях можно слушать аудио, скачать через торрент в формате fb2 и присутствует краткое содержание. Город: New York, Год выпуска: 2009, ISBN: 2009, Издательство: Apress, Жанр: Программирование, на английском языке. Описание произведения, (предисловие) а так же отзывы посетителей доступны на портале библиотеки ЛибКат.

Beginning Android: краткое содержание, описание и аннотация

Предлагаем к чтению аннотацию, описание, краткое содержание или предисловие (зависит от того, что написал сам автор книги «Beginning Android»). Если вы не нашли необходимую информацию о книге — напишите в комментариях, мы постараемся отыскать её.

Master Android from first principles and begin the journey toward your own successful Android applications!
Dear Reader,
First, welcome to the world of Android! We’re entering a new era of mobile application development, one marked by open platforms and open source, to take ‘walled gardens’ and make them green houses for any and all to participate in. Android is relatively easy for developers, and I believe that this innovation will help generate a large ecosystem of developers and consumers within a very short time. This means that budding developers such as yourself will have many opportunities to design and build your own applications and you’ll have a huge and hungry customer base.
Second, welcome to the book! Its purpose is to start you on your way with building Android applications, and to help you master the learning curve. Android is already a rich framework, comparable in many ways to the richness Android of desktop Java environments. This means that there is a lot of cool stuff for you to pick up along your journey in order to create the slickest, most useful apps Android you can imagine.
The source code for the code samples in this book is all available from the Apress site, so you can stay as hands-on and practical as you like while I introduce you to the core of Android, and invite you to experiment with the various classes and APIs we’ll be looking at. By the time you’ve finished this book, you’ll be creating your own Android applications and asking yourself what your next great application will be…!
Enjoy! Mark Murphy

Beginning Android — читать онлайн бесплатно полную книгу (весь текст) целиком

Ниже представлен текст книги, разбитый по страницам. Система сохранения места последней прочитанной страницы, позволяет с удобством читать онлайн бесплатно книгу «Beginning Android», без необходимости каждый раз заново искать на чём Вы остановились. Поставьте закладку, и сможете в любой момент перейти на страницу, на которой закончили чтение.

Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

boundCenterBottom(marker);

}

@Override

protectedboolean onTap(int i) {

Toast. makeText(NooYawk. this,

items. get(i). getSnippet(), Toast.LENGTH_SHORT). show();

return( true);

}

@Override

publicint size() {

return(items. size());

}

}

Handling Screen Taps

An Overlaysubclass can also implement onTap(), to be notified when the user taps on the map, so the overlay can adjust what it draws. For example, in full-size Google Maps, clicking on a push-pin pops up a bubble with information about the business at that pin’s location. With onTap(), you can do much the same in Android.

The onTap()method for ItemizedOverlayreceives the index of the OverlayItemthat was clicked. It is up to you to do something worthwhile with this event.

In the case of SitesOverlay, as previously shown, onTap()looks like this:

@Override

protectedboolean onTap(int i) {

Toast. makeText(NooYawk. this,

items. get(i). getSnippet(), Toast.LENGTH_SHORT). show();

return( true);

}

Here, we just toss up a short Toastwith the “snippet” from the OverlayItem, returning true to indicate we handled the tap.

My, Myself, and MyLocationOverlay

Android has a built-in overlay to handle two common scenarios:

• Showing where you are on the map, based on GPS or other location-providing logic

• Showing where you are pointed, based on the built-in compass sensor, where available

All you need to do is create a MyLocationOverlayinstance, add it to your MapView’s list of overlays, and enable and disable the desired features at appropriate times.

The “at appropriate times” notion is for maximizing battery life. There is no sense in updating locations or directions when the activity is paused, so it is recommended that you enable these features in onResume()and disable them in onPause().

For example, NooYawkwill display a compass rose using MyLocationOverlay. To do this, we first need to create the overlay and add it to the list of overlays:

me = new MyLocationOverlay( this, map);

map. getOverlays(). add(me);

Then, we enable and disable the compass rose as appropriate:

@Override

publicvoid onResume() {

super. onResume();

me. enableCompass();

}

@Override

publicvoid onPause() {

super. onPause();

me. disableCompass();

}

The Key to It All

If you actually download the source code for the book, compile the NooYawk project, install it in your emulator, and run it, you will probably see a screen with a grid and a couple of pushpins, but no actual maps.

That’s because the API key in the source code is invalid for your development machine. Instead, you will need to generate your own API key(s) for use with your application.

Full instructions for generating API keys, for development and production use, can be found on the Android Web site. [33] http://code.google.com/android/toolbox/apis/mapkey.html In the interest of brevity, let’s focus on the narrow case of getting NooYawk running in your emulator. Doing this requires the following steps:

1. Visit the API key signup page and review the terms of service.

2. Re-read those terms of service and make really, really sure you want to agree to them.

3. Find the MD5 digest of the certificate used for signing your debug-mode applications (described in detail in the following).

4. On the API key signup page, paste in that MD5 signature and submit the form.

5. On the resulting page, copy the API key and paste it as the value of apiKeyin your MapView-using layout.

The trickiest part is finding the MD5 signature of the certificate used for signing your debug-mode applications… and much of the complexity is merely in making sense of the concept.

All Android applications are signed using a digital signature generated from a certificate. You are automatically given a debug certificate when you set up the SDK, and there is a separate process for creating a self-signed certificate for use in your production applications. This signature process involves the use of the Java keytooland jarsignerutilities. For the purposes of getting your API key, you only need to worry about keytool.

To get your MD5 digest of your debug certificate, if you are on OS X or Linux, use the following command:

keytool -list -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass

android -keypass android

On other development platforms, you will need to replace the value of the -keystoreswitch with the location for your platform and user account:

• Windows XP: C:\Documents and Settings\\Local Settings\Application Data\Android\debug.keystore

• Windows Vista: C:\Users\\AppData\Local\Android\debug.keystore

(where is your account name)

The second line of the output contains your MD5 digest, as a series of pairs of hex digits separated by colons.

CHAPTER 35

Handling Telephone Calls

Many, if not most, Android devices will be phones. As such, not only will users be expecting to place and receive calls using Android, but you will have the opportunity to help them place calls, if you wish.

Why might you want to?

• Maybe you are writing an Android interface to a sales management application (a la Salesforce.com) and you want to offer users the ability to call prospects with a single button click, and without them having to keep those contacts both in your application and in the phone’s contacts application

• Maybe you are writing a social networking application, and the roster of phone numbers that you can access shifts constantly, so rather than try to “sync” the social network contacts with the phone’s contact database, you let people place calls directly from your application

• Maybe you are creating an alternative interface to the existing contacts system, perhaps for users with reduced motor control (e.g., the elderly), sporting big buttons and the like to make it easier for them to place calls

Whatever the reason, Android has the means to let you manipulate the phone just like any other piece of the Android system.

Report to the Manager

To get at much of the phone API, you use the TelephonyManager. That class lets you do things like:

Читать дальше
Тёмная тема
Сбросить

Интервал:

Закладка:

Сделать

Похожие книги на «Beginning Android»

Представляем Вашему вниманию похожие книги на «Beginning Android» списком для выбора. Мы отобрали схожую по названию и смыслу литературу в надежде предоставить читателям больше вариантов отыскать новые, интересные, ещё непрочитанные произведения.


Отзывы о книге «Beginning Android»

Обсуждение, отзывы о книге «Beginning Android» и просто собственные мнения читателей. Оставьте ваши комментарии, напишите, что Вы думаете о произведении, его смысле или главных героях. Укажите что конкретно понравилось, а что нет, и почему Вы так считаете.

x