<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5293931621561625477</id><updated>2024-09-19T14:46:07.158-07:00</updated><category term="Flex"/><title type='text'>Anass Boukalane</title><subtitle type='html'>it&#39;s a blog about different technologies that i like play with ;-)&#xa;Flex , Java , Ajax...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://aboukalane.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://aboukalane.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anass Boukalane</name><uri>http://www.blogger.com/profile/16556828831189033073</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVoEpeQ7RRt9QoDSz9_B4NUEee0neBxVDTZyjWrA0MM1wGVdKB41JmtTo5ey8qk9ricJ7ZNInEVtCCRso0XIhVJfxHDMBIDWW5-4NnSdici-oHWA3Y-hSua_WaDwdQZDU/s220/IMG_0000_28.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5293931621561625477.post-6904445478589831923</id><published>2012-06-06T06:35:00.003-07:00</published><updated>2012-06-06T06:35:51.590-07:00</updated><title type='text'>Android for Beginners</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: red; font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;The Android platform&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: red; font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Android is a software environment built for mobile devices. It’s not a hardware platform.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Android includes a Linux kernel-based OS, a rich UI, end-user applications,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;code libraries, application frameworks, multimedia support, and much more. And,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;yes, even telephone functionality is included! Whereas components of the underlying&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;OS are written in C or C++, user applications are built&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;for Android in Java. Even the built-in applications are&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;written in Java. With the exception of some Linux&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;exploratory exercises in chapter 13 and the Native&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Developer Kit (NDK) in chapter 19, all the code&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;examples in this book are written in Java, using the&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Android software development kit (SDK).&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;One feature of the Android platform is that&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;there’s no difference between the built-in applications&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;and applications that you create with the SDK.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This means that you can write powerful applications&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;to tap into the resources available on the device. Figure&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;1.1 shows the relationship between Android and&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;the hardware it runs on. The most notable feature of&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Android might be that it’s open source; missing elements&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;can and will be provided by the global developer&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;community. Android’s Linux kernel-based OS&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;doesn’t come with a sophisticated shell environment,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;but because the platform is open, you can write and&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;install shells on a device. Likewise, multimedia codecs&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;can be supplied by third-party developers and don’t&amp;nbsp;need to rely on Google or anyone else to provide new functionality. That’s the power&amp;nbsp;of an open source platform brought to the mobile market.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;color: red; font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;The layers of Android&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red; font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: red; font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The Android stack includes an impressive array of features for mobile applications. In&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;fact, looking at the architecture alone, without the context of Android being a platform&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;designed for mobile environments, it would be easy to confuse Android with a&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;general computing environment. All the major components of a computing platform&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;are there. Here’s a quick rundown of prominent components of the Android stack:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt; A Linux kernel that provides a foundational hardware abstraction layer, as well as&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;core services such as process, memory, and filesystem management. The kernel&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;is where hardware-specific drivers are implemented—capabilities such as Wi-Fi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;and Bluetooth are here. The Android stack is designed to be flexible, with&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;many optional components that largely rely on the availability of specific hardware&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;on a given device. These components include features such as touch&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;screens, cameras, GPS receivers, and accelerometers.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt; Prominent code libraries, including the following:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Browser technology from WebKit, the same open source engine powering&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Mac’s Safari and the iPhone’s Mobile Safari browser. WebKit has become the&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;de facto standard for most mobile platforms.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Database support via SQLite, an easy-to-use SQL database.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Advanced graphics support, including 2D, 3D, animation from Scalable&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Games Language (SGL), and OpenGL ES.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Audio and video media support from PacketVideo’s OpenCORE, and&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Google’s own Stagefright media framework.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Secure Sockets Layer (SSL) capabilities from the Apache project.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt; An array of managers that provide services for&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Activities and views&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Windows&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Location-based services&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Telephony&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Resources&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;(continued)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Contrast Apple’s approach to application distribution with the freedom Android&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;developers enjoy to ship applications via traditional venues such as freeware and&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;shareware, and commercially through various marketplaces, including their own&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;website! For software publishers who want the focus of an on-device shopping experience,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Google has launched and continues to mature the Android Market. For software&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;developers who already have titles for other platforms such as Windows&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Mobile, Palm, and BlackBerry, traditional software markets such as Handango&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;(www.Handango.com) also support selling Android applications. Handango and its&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;ilk are important outlets; consumers new to Android will likely visit sites such as&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Handango because that might be where they first purchased one of their favorite&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;applications for their prior device.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The layers of Android 11&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt; The Android runtime, which provides&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• Core Java packages for a nearly full-featured Java programming environment.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Note that this isn’t a Java ME environment.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;• The Dalvik VM, which employs services of the Linux-based kernel to provide an&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;environment to host Android applications.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;
&lt;span style=&quot;color: red; font-family: Verdana, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;The Intent of Android development&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Let’s jump into the fray of Android development, focus on an important component&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;of the Android platform, and expand to take a broader view of how Android applications&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;are constructed.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;An important and recurring theme of Android development is the Intent. An&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Intent in Android describes what you want to do. An Intent might look like “I want&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;to look up a contact record” or “Please launch this website” or “Show the order confirmation&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;screen.” Intents are important because they not only facilitate navigation in&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;an innovative way, as we’ll discuss next, but also represent the most important aspect&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;of Android coding. Understand the Intent and you’ll understand Android.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;NOTE Instructions for setting up the Eclipse development environment are in&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;appendix A. This environment is used for all Java examples in this book. Chapter&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;2 goes into more detail on setting up and using the development tools.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The code examples in this chapter are primarily for illustrative purposes.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We reference and introduce classes without necessarily naming specific Java&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;packages. Subsequent chapters take a more rigorous approach to introducing&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Android-specific packages and classes.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Next, we’ll look at the foundational information about why Intents are important,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and then we’ll describe how Intents work. Beyond the introduction of the Intent,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;the remainder of this chapter describes the major elements of Android application&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;development, leading up to and including the first complete Android application that&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;you’ll develop.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;div&gt;
&lt;span style=&quot;color: red; font-size: large;&quot;&gt;&lt;b&gt;Four kinds of Android components&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Let’s build on your knowledge of the Intent and IntentFilter classes and explore&lt;/div&gt;
&lt;div&gt;
the four primary components of Android applications, as well as their relation to the&lt;/div&gt;
&lt;div&gt;
Android process model. We’ll include code snippets to provide a taste of Android&lt;/div&gt;
&lt;div&gt;
application development. We’re going to leave more in-depth examples and discussion&lt;/div&gt;
&lt;div&gt;
for later chapters.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Activity&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
An application might have a UI, but it doesn’t have to have one. If it has a UI, it’ll have&lt;/div&gt;
&lt;div&gt;
at least one Activity.&lt;/div&gt;
&lt;div&gt;
The easiest way to think of an Android Activity is to relate it to a visible screen,&lt;/div&gt;
&lt;div&gt;
because more often than not there’s a one-to-one relationship between an Activity&lt;/div&gt;
&lt;div&gt;
and a UI screen. This relationship is similar to that of a controller in the MVC paradigm.&lt;/div&gt;
&lt;div&gt;
Android applications often contain more than one Activity. Each Activity displays&lt;/div&gt;
&lt;div&gt;
a UI and responds to system- and user-initiated events. The Activity employs&lt;/div&gt;
&lt;div&gt;
one or more Views to present the actual UI elements to the user.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Service&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
If an application is to have a long lifecycle, it’s often best to put it into a Service. For&lt;/div&gt;
&lt;div&gt;
example, a background data-synchronization utility should be implemented as a&lt;/div&gt;
&lt;div&gt;
Service. A best practice is to launch Services on a periodic or as-needed basis, triggered&lt;/div&gt;
&lt;div&gt;
by a system alarm, and then have the Service terminate when its task is complete.&lt;/div&gt;
&lt;div&gt;
Like the Activity, a Service is a class in the Android runtime that you should&lt;/div&gt;
&lt;div&gt;
extend, as shown in the following listing.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;BroadcastReceiver&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
If an application wants to receive and respond to a global event, such as a ringing&lt;/div&gt;
&lt;div&gt;
phone or an incoming text message, it must register as a BroadcastReceiver. An&lt;/div&gt;
&lt;div&gt;
application registers to receive Intents in one of the following ways:&lt;/div&gt;
&lt;div&gt;
 The application can implement a &lt;receiver&gt; element in the Android-&lt;/receiver&gt;&lt;/div&gt;
&lt;div&gt;
Manfest.xml file, which describes the BroadcastReceiver’s class name and&lt;/div&gt;
&lt;div&gt;
enumerates its IntentFilters. Remember, the IntentFilter is a descriptor of&lt;/div&gt;
&lt;div&gt;
the Intent an application wants to process. If the receiver is registered in the&lt;/div&gt;
&lt;div&gt;
AndroidManifest.xml file, the application doesn’t need to be running in order&amp;nbsp;to be triggered. When the event occurs, the application is started automatically&lt;/div&gt;
&lt;div&gt;
upon notification of the triggering event. Thankfully, all this housekeeping is&lt;/div&gt;
&lt;div&gt;
managed by the Android OS itself.&lt;/div&gt;
&lt;div&gt;
 An application can register at runtime via the Context class’s register-&lt;/div&gt;
&lt;div&gt;
Receiver method.&lt;/div&gt;
&lt;div&gt;
Like Services, BroadcastReceivers don’t have a UI. Even more important, the code&lt;/div&gt;
&lt;div&gt;
running in the onReceive method of a BroadcastReceiver should make no assumptions&lt;/div&gt;
&lt;div&gt;
about persistence or long-running operations. If the BroadcastReceiver&lt;/div&gt;
&lt;div&gt;
requires more than a trivial amount of code execution, it’s recommended that the&lt;/div&gt;
&lt;div&gt;
code initiate a request to a Service to complete the requested functionality because&lt;/div&gt;
&lt;div&gt;
the Service application component is designed for longer-running operations&lt;/div&gt;
&lt;div&gt;
whereas the BroadcastReceiver is meant for responding to various triggers.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;ContentProvider&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
If an application manages data and needs to expose that data to other applications&lt;/div&gt;
&lt;div&gt;
running in the Android environment, you should consider a ContentProvider. If an&lt;/div&gt;
&lt;div&gt;
application component (Activity, Service, or BroadcastReceiver) needs to access&lt;/div&gt;
&lt;div&gt;
data from another application, the component accesses the other application’s&lt;/div&gt;
&lt;div&gt;
ContentProvider. The ContentProvider implements a standard set of methods to&lt;/div&gt;
&lt;div&gt;
permit an application to access a data store. The access might be for read or write&lt;/div&gt;
&lt;div&gt;
operations, or for both. A ContentProvider can provide data to an Activity or&lt;/div&gt;
&lt;div&gt;
Service in the same containing application, as well as to an Activity or Service contained&lt;/div&gt;
&lt;div&gt;
in other applications.&lt;/div&gt;
&lt;div&gt;
A ContentProvider can use any form of data-storage mechanism available on the&lt;/div&gt;
&lt;div&gt;
Android platform, including files, SQLite databases, or even a memory-based hash&lt;/div&gt;
&lt;div&gt;
map if data persistence isn’t required. The ContentProvider is a data layer that provides&lt;/div&gt;
&lt;div&gt;
data abstraction for its clients and centralizing storage and retrieval routines in a&lt;/div&gt;
&lt;div&gt;
single place.&lt;/div&gt;
&lt;div&gt;
Sharing files or databases directly is discouraged on the Android platform, and is&lt;/div&gt;
&lt;div&gt;
enforced by the underlying Linux security system, which prevents ad hoc file access&lt;/div&gt;
&lt;div&gt;
from one application space to another without explicitly granted permissions.&lt;/div&gt;
&lt;div&gt;
Data stored in a ContentProvider can be traditional data types, such as integers and&lt;/div&gt;
&lt;div&gt;
strings. Content providers can also manage binary data, such as image data. When&lt;/div&gt;
&lt;div&gt;
binary data is retrieved, the suggested best practice is to return a string representing&lt;/div&gt;
&lt;div&gt;
the filename that contains the binary data&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aboukalane.blogspot.com/feeds/6904445478589831923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aboukalane.blogspot.com/2012/06/android-for-beginners.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/6904445478589831923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/6904445478589831923'/><link rel='alternate' type='text/html' href='http://aboukalane.blogspot.com/2012/06/android-for-beginners.html' title='Android for Beginners'/><author><name>Anass Boukalane</name><uri>http://www.blogger.com/profile/16556828831189033073</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVoEpeQ7RRt9QoDSz9_B4NUEee0neBxVDTZyjWrA0MM1wGVdKB41JmtTo5ey8qk9ricJ7ZNInEVtCCRso0XIhVJfxHDMBIDWW5-4NnSdici-oHWA3Y-hSua_WaDwdQZDU/s220/IMG_0000_28.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5293931621561625477.post-4981699317531312857</id><published>2009-09-10T04:17:00.000-07:00</published><updated>2009-09-10T04:17:35.412-07:00</updated><title type='text'>Introduction à log4j</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #606a6d; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1 style=&quot;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 35px; font-weight: bold; letter-spacing: -2px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 3px; padding-left: 0px; padding-right: 20px; padding-top: 0px; text-decoration: none; text-transform: capitalize;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;introduction_a_log4j_-_java&quot; name=&quot;introduction_a_log4j_-_java&quot; style=&quot;font-size: 25px; font-weight: bolder; left: 670px; letter-spacing: -2px; text-decoration: none; top: 236px;&quot;&gt;&lt;span style=&quot;color: #674ea7;&quot;&gt;Introduction À Log4j - Java&lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;&lt;div class=&quot;level1&quot;&gt;log4j est un framework extensible qui permet de logger et débugger vos applications Java. Lorsqu’on commence à l’utiliser, il devient impossible de s’en passer tellement il est pratique. C’est gratuit et opensource. (&lt;em&gt;Apache Software License 1.1&lt;/em&gt;)&lt;/div&gt;&lt;h2 style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;objectifs&quot; name=&quot;objectifs&quot; style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Objectifs&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;level2&quot;&gt;Dans ce tutoriel nous allons apprendre les bases de log4j :&lt;br /&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;Concepts fondamentaux&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;Installation&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;Configuration&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;Utilisation&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;prerequis&quot; name=&quot;prerequis&quot; style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Prérequis&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;level2&quot;&gt;&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;Connaître les bases de Java&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;h2 style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;concepts_fondamentaux&quot; name=&quot;concepts_fondamentaux&quot; style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Concepts fondamentaux&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;level2&quot;&gt;Le framework utilise trois types de composant :&lt;br /&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;Logger&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;Appender&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;Layout&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;Ces composants communiquent entre eux pour déterminer :&lt;br /&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;Quel messages doivent être loggés&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;La façon de logger les messages&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;La présentation des messages&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;h3 style=&quot;text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;logger&quot; name=&quot;logger&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;Logger&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;level3&quot;&gt;Le Logger est le point d’entrée d’un message. C’est pratiquement une des seules classes que nous allons utiliser.&lt;br /&gt;
log4j gère les Logger de façon hiérarchique. C’est à dire qu’un Logger peut avoir des enfants et des parents. La hiérarchie est gérée par le nom des Logger. Les niveaux sont définis par des points, un peu comme la structure des packages de classes. Par exemple :&lt;br /&gt;
&lt;pre class=&quot;code java&quot;&gt;com 
com.&lt;span class=&quot;me1&quot;&gt;liguo&lt;/span&gt;
com.&lt;span class=&quot;me1&quot;&gt;liguo&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;layout&lt;/span&gt;&lt;/pre&gt;&lt;em&gt;com&lt;/em&gt;&amp;nbsp;est le parent de&amp;nbsp;&lt;em&gt;com.liguo&lt;/em&gt;&amp;nbsp;et l’ancêtre de&amp;nbsp;&lt;em&gt;com.liguo.layout&lt;/em&gt;&lt;br /&gt;
log4j possède par défaut un Logger à la racine de la hiérarchie. Il se nomme&amp;nbsp;&lt;strong&gt;rootLogger&lt;/strong&gt;.&lt;br /&gt;
Lorsque l’on demande à log4j de créer un Logger, il vérifie dans la configuration s’il y a quelque chose de défini pour celui-ci. S’il ne trouve rien, il remonte dans la hiérarchie jusqu’à ce qu’il trouve quelque chose. C’est pourquoi le rootLogger qui est à la racine est très important.&lt;/div&gt;&lt;h3 style=&quot;text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;appender&quot; name=&quot;appender&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;Appender&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;level3&quot;&gt;Appender est une interface dont le rôle est de :&lt;br /&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;Filtrer les messages&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;Déterminer le mode de sortie des messages selon l’implémentation&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;Un logger peut avoir un nombre X d’appender. Pour ajouter un appender manuellement (je n’ai jamais eu à le faire), il suffit de faire :&lt;br /&gt;
&lt;pre class=&quot;code java&quot;&gt;monLogger.&lt;span class=&quot;me1&quot;&gt;addAppender&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;monAppender&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;;&lt;/pre&gt;&lt;strong&gt;Note&lt;/strong&gt;&amp;nbsp;: Un Logger utilise les appender de ses ancêtres. Donc les appender définis pour le&amp;nbsp;&lt;em&gt;rootLogger&lt;/em&gt;&amp;nbsp;seront utilisés par&amp;nbsp;&lt;strong&gt;tous&lt;/strong&gt;les Logger, peu importe leur niveau.&lt;br /&gt;
log4j fournit de base les appender utilisés pour les tâches courantes :&lt;br /&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;&lt;a class=&quot;urlextern&quot; href=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/ConsoleAppender.html&quot; rel=&quot;nofollow&quot; style=&quot;color: black; text-decoration: none;&quot; title=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/ConsoleAppender.html&quot;&gt;ConsoleAppender&lt;/a&gt;&amp;nbsp;- envoie les messages dans la console du système (cf. Tomcat dans le cadre d’une application web)&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;&lt;a class=&quot;urlextern&quot; href=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/FileAppender.html&quot; rel=&quot;nofollow&quot; style=&quot;color: black; text-decoration: none;&quot; title=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/FileAppender.html&quot;&gt;FileAppender&lt;/a&gt;&amp;nbsp;- envoie les messages dans un fichier&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;&lt;a class=&quot;urlextern&quot; href=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/net/SocketAppender.html&quot; rel=&quot;nofollow&quot; style=&quot;color: black; text-decoration: none;&quot; title=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/net/SocketAppender.html&quot;&gt;SocketAppender&lt;/a&gt;&amp;nbsp;- envoie les messages dans un Socket&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;&lt;a class=&quot;urlextern&quot; href=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/net/SMTPAppender.html&quot; rel=&quot;nofollow&quot; style=&quot;color: black; text-decoration: none;&quot; title=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/net/SMTPAppender.html&quot;&gt;SMTPAppender&lt;/a&gt;&amp;nbsp;- envoie les messages par mail&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;Il en existe d’autres pour les utilisateurs plus avancés et il est évidemment possible de créer son propre appender custom en implémentant l’interface&amp;nbsp;&lt;a class=&quot;urlextern&quot; href=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/Appender.html&quot; rel=&quot;nofollow&quot; style=&quot;color: black; text-decoration: none;&quot; title=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/Appender.html&quot;&gt;org.apache.log4j.Appender&lt;/a&gt;&lt;/div&gt;&lt;h3 style=&quot;text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;layout&quot; name=&quot;layout&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;Layout&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;level3&quot;&gt;Les Layout définissent le format du message. Je peux par exemple avoir la date, l’heure, le nom de la classe qui envoie le message et le niveau de logging au début de chaque message. C’est le rôle du Layout de faire ça et non celui du développeur qui envoie le message.&lt;/div&gt;&lt;h3 style=&quot;text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;niveau&quot; name=&quot;niveau&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;Niveau&lt;/a&gt;&lt;/h3&gt;&lt;div class=&quot;level3&quot;&gt;Lorsqu’on envoie un message à un logger, il faut spécifier un niveau. Par défaut log4j offre les niveaux suivants :&lt;br /&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;DEBUG&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;INFO&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;WARN&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;ERROR&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt;FATAL&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;Les niveaux sont gérés par ordre de priorité, DEBUG étant le moins important.&lt;br /&gt;
Par exemple, durant la période de développement, on utilise le niveau DEBUG. Une fois que l’application est déployée en production, on change le niveau pour WARN afin d’&lt;strong&gt;ignorer&lt;/strong&gt;&amp;nbsp;les messages de debugage,&amp;nbsp;&lt;strong&gt;Sans modifier une seule ligne dans notre code.&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Note&lt;/strong&gt;&amp;nbsp;: Il est possible de créer ses propres niveaux.&lt;/div&gt;&lt;h2 style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;installation&quot; name=&quot;installation&quot; style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Installation&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;level2&quot;&gt;Bon c’est fini pour la théorie, passons maintenant aux choses sérieuses.&lt;br /&gt;
Il faut tout d’abord aller sur le site de la fondation Apache pour télécharger log4j :&lt;br /&gt;
&lt;a class=&quot;urlextern&quot; href=&quot;http://logging.apache.org/log4j/docs/download.html&quot; rel=&quot;nofollow&quot; style=&quot;color: black; text-decoration: none;&quot; title=&quot;http://logging.apache.org/log4j/docs/download.html&quot;&gt;http://logging.apache.org/log4j/docs/download.html&lt;/a&gt;&lt;br /&gt;
Télécharger la dernière version stable. Ensuite extraire l’archive dans n’importe quel répertoire de votre disque dur.&lt;br /&gt;
L’archive devrait avoir la structure de répertoires suivante :&lt;br /&gt;
&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;logging-log4j-x.x.x&lt;/div&gt;&lt;ul style=&quot;list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 20px; margin-left: 20px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt;build&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt;contribs&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt;dist&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt;docs&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt;exemples&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level3&quot;&gt;&lt;div class=&quot;li&quot;&gt;src&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;Le répertoire&amp;nbsp;&lt;strong&gt;dist&lt;/strong&gt;&amp;nbsp;devrait contenir un sous-répertoire&amp;nbsp;&lt;strong&gt;lib&lt;/strong&gt;. Ce dernier devrait contenir le fichier&amp;nbsp;&lt;strong&gt;log4j-x.x.x.jar&lt;/strong&gt;&amp;nbsp;(remplacez x.x.x par le numéro de version)&lt;br /&gt;
Pour installer log4j, il suffit d’inclure le fichier&amp;nbsp;&lt;strong&gt;log4j-x.x.x.jar&lt;/strong&gt;&amp;nbsp;dans le classpath. Dans le cas d’une application web avec Tomcat, c’est dans le répertoire&amp;nbsp;&lt;strong&gt;/WEB-INF/lib&lt;/strong&gt;&lt;br /&gt;
Et voilà, c’est fini pour l’installation.&lt;/div&gt;&lt;h2 style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;configuration&quot; name=&quot;configuration&quot; style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Configuration&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;level2&quot;&gt;Il existe plusieurs façons de configurer log4j. Celle que nous allons utiliser est assez simple et souple. Nous allons mettre ça dans un fichier de propriétés externe. Donc pas besoin de recompiler notre code pour modifier la configuration.&lt;br /&gt;
Créez tout d’abord un fichier nommé&amp;nbsp;&lt;strong&gt;log4j.properties&lt;/strong&gt;&amp;nbsp;et sauvegardez le dans le classpath de votre application. Dans le cas d’une application web avec Tomcat, c’est dans le répertoire&amp;nbsp;&lt;strong&gt;/WEB-INF/classes&lt;/strong&gt;&lt;br /&gt;
Voici le contenu de notre fichier : (les lignes avec un # sont des commentaires)&lt;br /&gt;
&lt;pre class=&quot;code perl&quot;&gt;&lt;span class=&quot;co1&quot;&gt;#définition du niveau et des Appender du rootLogger&lt;/span&gt;
log4j.rootLogger=DEBUG, monAppender
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;#configuration de &quot;monAppender&quot;&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;#nous allons envoyer les messages dans la console de Tomcat&lt;/span&gt;
log4j.appender.monAppender=org.apache.log4j.ConsoleAppender
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;#définition du Layout pour &quot;monAppender&quot;&lt;/span&gt;
log4j.appender.monAppender.layout=org.apache.log4j.PatternLayout
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;#définition du pattern d&#39;affichage pour &quot;monAppender&quot;&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;#voici un exemple de sortie que l&#39;on va obtenir : 2005-06-18 14:53:37 DEBUG [Main] Hello World&lt;/span&gt;
log4j.appender.monAppender.layout.ConversionPattern=&lt;span class=&quot;re0&quot;&gt;%d&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;yyyy-MM-dd HH:mm:ss&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt; %-5p &lt;span class=&quot;br0&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;%c&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;re0&quot;&gt;%m&lt;/span&gt;&lt;span class=&quot;re0&quot;&gt;%n&lt;/span&gt;&lt;/pre&gt;Pour avoir plus d’infos sur la construction d’un pattern, aller faire un tour sur cette&amp;nbsp;&lt;a class=&quot;urlextern&quot; href=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html&quot; rel=&quot;nofollow&quot; style=&quot;color: black; text-decoration: none;&quot; title=&quot;http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html&quot;&gt;page&lt;/a&gt;&lt;br /&gt;
Si par exemple je veux modifier le niveau de logging des classes se trouvant dans le package com.liguo.layout, je n’ai qu’à ajouter la ligne suivante dans le fichier de configuration :&lt;br /&gt;
&lt;pre class=&quot;code perl&quot;&gt;log4j.logger.com.liguo.layout=WARN&lt;/pre&gt;&lt;/div&gt;&lt;h2 style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;utilisation&quot; name=&quot;utilisation&quot; style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Utilisation&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;level2&quot;&gt;Pour l’utilisation, je vais reprendre une simple classe&lt;br /&gt;
&lt;pre class=&quot;code java&quot;&gt;&lt;span class=&quot;co2&quot;&gt;import org.apache.log4j.Logger;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt; HelloService &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
&amp;nbsp;
        &lt;span class=&quot;coMULTI&quot;&gt;/**
         *déclaration et création du Logger 
         *on le met statique afin d&#39;économiser la mémoire
         */&lt;/span&gt;
        &lt;span class=&quot;kw2&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;static&lt;/span&gt; Logger logger = Logger.&lt;span class=&quot;me1&quot;&gt;getLogger&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;HelloService.&lt;span class=&quot;kw2&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;;
&amp;nbsp;
 &lt;span class=&quot;kw2&quot;&gt;public&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3AString+java.sun.com&amp;amp;bntI=I%27m%20Feeling%20Lucky&quot; style=&quot;color: black; text-decoration: none;&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;String&lt;/span&gt;&lt;/a&gt; helloWorld&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
                logger.&lt;span class=&quot;me1&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Le service helloWorld est invoqué&quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;;
  &lt;span class=&quot;kw2&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&quot;Hello, world&quot;&lt;/span&gt;;
 &lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;Si jamais la construction du message est lourde (transformation d’un&amp;nbsp;&lt;acronym title=&quot;Document Object Model&quot;&gt;DOM&lt;/acronym&gt;&amp;nbsp;&lt;acronym title=&quot;Extensible Markup Language&quot;&gt;XML&lt;/acronym&gt;&amp;nbsp;en String, concanénation de String, conversion de valeur numérique en String, etc..), il suffit d’utiliser la méthode isDebugEnabled() afin de vérifier si le logger ignorera ou non ce message.&lt;br /&gt;
&lt;pre class=&quot;code java&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;logger.&lt;span class=&quot;me1&quot;&gt;isDebugEnabled&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;{&lt;/span&gt;
   logger.&lt;span class=&quot;me1&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&quot;Affiche de la section #&quot;&lt;/span&gt; + sectionId&lt;span class=&quot;br0&quot;&gt;)&lt;/span&gt;;
&lt;span class=&quot;br0&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 style=&quot;color: #424242; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;&lt;a href=&quot;&quot; id=&quot;conclusion&quot; name=&quot;conclusion&quot; style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: bold; letter-spacing: -1px; line-height: 30px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none;&quot;&gt;Conclusion&lt;/a&gt;&lt;/h2&gt;&lt;div class=&quot;level2&quot;&gt;Tout ceci est suffisant pour utiliser log4j, mais ce n’est qu’un bref aperçu de tout ce qu’il peut faire. Étant un framework extensible, la seule limite à son utilisation est l’imagination du développeur !&lt;br /&gt;
Exemple simple : on pourrait décider d’envoyer un mail aux développeurs pour les messages de niveau ERROR et FATAL qui sont lancés dans une application qui est en production. De cette façon, on est toujours au courant de l’état de notre application sur le serveur sans toujours avoir les yeux collés sur le fichier de log.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://aboukalane.blogspot.com/feeds/4981699317531312857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aboukalane.blogspot.com/2009/09/introduction-log4j.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/4981699317531312857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/4981699317531312857'/><link rel='alternate' type='text/html' href='http://aboukalane.blogspot.com/2009/09/introduction-log4j.html' title='Introduction à log4j'/><author><name>Anass Boukalane</name><uri>http://www.blogger.com/profile/16556828831189033073</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVoEpeQ7RRt9QoDSz9_B4NUEee0neBxVDTZyjWrA0MM1wGVdKB41JmtTo5ey8qk9ricJ7ZNInEVtCCRso0XIhVJfxHDMBIDWW5-4NnSdici-oHWA3Y-hSua_WaDwdQZDU/s220/IMG_0000_28.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5293931621561625477.post-6990780183854488989</id><published>2009-09-07T20:37:00.000-07:00</published><updated>2009-09-08T05:05:56.594-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Flex"/><title type='text'>Flex and XML, or E4X.</title><content type='html'>Flex 3 and ActionScript 3.0 provide ECMAScript for XML, or E4X, implementation&lt;br /&gt;
that enables you to work with dot notation to access the nodes within an XML hierarchy.&lt;br /&gt;
E4X provides a simplified shorthand notation so you can access specific nodes or&lt;br /&gt;
sets of nodes by name or by index without complicated custom recursive functions. It&lt;br /&gt;
also defines methods and properties for accessing all parts of the XML object, including&lt;br /&gt;
comments, namespaces, and processing instructions. The Flex Framework and ActionScript&lt;br /&gt;
3.0 define two low-level objects for working with XML: the XML object and&lt;br /&gt;
the XMLList object. The XML object represents a single XML element, an XML document&lt;br /&gt;
with multiple children, or a single-value element within a document. The XMLList object&lt;br /&gt;
represents a set of XML elements that are siblings of one another. XMLList objects do&lt;br /&gt;
not require a top-level node, for example:&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;item id=&quot;2&quot; name=&quot;Chewing Gum&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;item id=&quot;3&quot; name=&quot;Cotton Candy&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;item id=&quot;4&quot; name=&quot;Candy Bar&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
XML objects do require a top-level node:&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;order&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;item id=&quot;2&quot; name=&quot;Chewing Gum&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;item id=&quot;3&quot; name=&quot;Cotton Candy&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;item id=&quot;4&quot; name=&quot;Candy Bar&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;/order&amp;gt;&lt;/span&gt;&lt;br /&gt;
To perform XML transformations or to build XML documents, both the XML and&lt;br /&gt;
XMLList objects define methods to append, rename, and re-parent nodes within an XML&lt;br /&gt;
document. To perform queries, access particular attributes, or filter XML documents,&lt;br /&gt;
use the E4X querying syntax. For working with XML namespaces, the XMLUtil class&lt;br /&gt;
defines methods of accessing and comparing namespaces.&lt;br /&gt;
&lt;br /&gt;
Load an XML File :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default, the HTTPService component converts any loaded XML into an ActionScript&lt;br /&gt;
object. To ensure that the HTTPService component does not convert the loaded XML&lt;br /&gt;
to an object, set the resultFormat property of the HTTPService object to E4X as shown:&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:HTTPService url=&quot;http://server/xmlDoc.xml&quot; id=&quot;xmlService&quot; resultFormat=&quot;e4x&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;result=&quot;xmlObj = XML(xmlService.lastResult)&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
The lastResult of the HTTPService is used to set the value of the xmlObj variable here.&lt;br /&gt;
If the XML file is static or you need to load it only once, it is easier and lighter to use&lt;br /&gt;
the flash.net.URLLoader class to load the data:&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;private var loader:URLLoader = new URLLoader();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;private function init():void {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;loader.addEventListener(Event.COMPLETE, setResult);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;var req:URLRequest = new URLRequest();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;req.url = &quot;http://server/xmlDoc.xml&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; loader.load(req);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;private function setResult(event:Event):void {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; trace(XML(loader.data).toString());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
The Event.COMPLETE event listener must be added to the URLLoader so that the application&lt;br /&gt;
can be notified when the file is finished being loaded. The loaded data is stored as&lt;br /&gt;
the URLLoader.data property and is not cast or altered at all. If the XML data will be&lt;br /&gt;
dynamically generated or will need to be loaded multiple times, it may be easier to load&lt;br /&gt;
the file by using HTTPService. A complete code listing using both methods is shown here:&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:VBox xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; width=&quot;400&quot; height=&quot;300&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;creationComplete=&quot;init()&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;!-- if the resultFormat is not set, then the result will be parsed as an Object --&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:HTTPService url=&quot;http://server/xmlDoc.xml&quot; id=&quot;xmlService&quot; resultFormat=&quot;e4x&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;result=&quot;xmlObj = XML(xmlService.lastResult)&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:Script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;![CDATA[&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;private var loader:URLLoader = new URLLoader();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;[Bindable]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;private var xmlObj:XML;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;private function init():void {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; loader.addEventListener(Event.COMPLETE, setResult);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;private function urlLoaderSend():void {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; var req:URLRequest = new URLRequest();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; req.url = &quot;http://server/xmlDoc.xml&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; loader.load(req);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;private function setResult(event:Event):void {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;xmlObj = (loader.data as XML)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;]]&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;/mx:Script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:Button click=&quot;xmlService.send()&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:Button click=&quot;urlLoaderSend()&quot; label=&quot;load via URLLoader&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:TextArea text=&quot;{xmlObj.toString()}&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;/mx:VBox&amp;gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://aboukalane.blogspot.com/feeds/6990780183854488989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aboukalane.blogspot.com/2009/09/flex-and-xml-or-e4x.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/6990780183854488989'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/6990780183854488989'/><link rel='alternate' type='text/html' href='http://aboukalane.blogspot.com/2009/09/flex-and-xml-or-e4x.html' title='&lt;b&gt;&lt;font color=&quot;blue&quot;&gt;Flex and XML, or E4X.&lt;/font&gt;&lt;/b&gt;'/><author><name>Anass Boukalane</name><uri>http://www.blogger.com/profile/16556828831189033073</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVoEpeQ7RRt9QoDSz9_B4NUEee0neBxVDTZyjWrA0MM1wGVdKB41JmtTo5ey8qk9ricJ7ZNInEVtCCRso0XIhVJfxHDMBIDWW5-4NnSdici-oHWA3Y-hSua_WaDwdQZDU/s220/IMG_0000_28.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5293931621561625477.post-7031923025709945935</id><published>2009-09-05T19:18:00.000-07:00</published><updated>2009-09-08T05:17:08.965-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Flex"/><title type='text'>your first google map on Flex</title><content type='html'>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;here is a sample about using google map api in order to create your first google map Application :&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: small; font-weight: bold;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Requirements :&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;adobe flex builder&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;the librerie from google &quot;map_flex_1_16.swc&quot; , you can download it from this link :&lt;br /&gt;
http://maps.googleapis.com/maps/flash/release/sdk.zip&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;b&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Steps :&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; line-height: 16px;&quot;&gt;&lt;span style=&quot;line-height: normal;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Before you begin coding your application, you should first set up a project within FlexBuilder. To do so, follow these simple steps:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Select&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;File-New-Flex Project&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;within FlexBuilder. The&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;New Flex Project&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;dialog box appears. Enter in the name for your project and a location to store files related to the project, leaving the&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Application Type&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;as a&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Web Application&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;    &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;div style=&quot;line-height: 16px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0.6em; padding-left: 0px; padding-right: 0px; padding-top: 0.5em;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img src=&quot;http://code.google.com/intl/fr-FR/apis/maps/documentation/flash/images/flex_createProject.png&quot; style=&quot;border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;/ol&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
Click&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Finish&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;and your project will be created. FlexBuilder will also automatically create a template&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;color: #007000; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;MXML&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;file, as shown below:&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img src=&quot;http://code.google.com/intl/fr-FR/apis/maps/documentation/flash/images/flex_newProject.png&quot; style=&quot;border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;/ol&gt;&lt;span style=&quot;font-size: 14px; font-weight: bold; line-height: 16px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Linking to the Google Maps API for Flash Library&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
Before you can compile your code, you will need to link it to the Google Maps API for Flash SWC file. To do so, select&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Project-Properties&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. A&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Properties&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;dialog box will appear for your project. Click on&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Flex Build Path&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;and then select the&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Library Path&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;tab:&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img src=&quot;http://code.google.com/intl/fr-FR/apis/maps/documentation/flash/images/flex_buildPath.png&quot; style=&quot;border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;/ol&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
Click&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Add SWC...&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;within the&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Library Path&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;pane. An&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Add SWC&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;dialog box will appear. Navigate to the location where you saved the Google Maps API for Flash SDK and select the appropriate&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;color: #007000; font-size: 10pt;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;lib/map_flex_*.swc&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;file and click&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;OK&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. (&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Note:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Make sure you select the correct SWC. FlexBuilder will not be able to use the non-Flex SWC library.) Your dialog box should now look like the following:&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img src=&quot;http://code.google.com/intl/fr-FR/apis/maps/documentation/flash/images/flex_addSwc.png&quot; style=&quot;border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;/ol&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
Click&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;OK&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. FlexBuilder will update your project and you return you to the Flex Development Perspective showing your skeleton MXML file.&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;img src=&quot;http://code.google.com/intl/fr-FR/apis/maps/documentation/flash/images/flex_createActionScript.png&quot; style=&quot;border-bottom-style: none; border-color: initial; border-left-style: none; border-right-style: none; border-top-style: none; border-width: initial; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot; /&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span style=&quot;line-height: 16px;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You may wish to test compilation of your skeleton MXML file at this point to ensure your development environment is working correctly.  open your mxml file and copy the following code :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;
&lt;h2 id=&quot;Source&quot; style=&quot;font-size: 17px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 1.5em;&quot;&gt;&lt;span style=&quot;font-size: medium; font-weight: normal;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: 17px;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 13px; font-weight: normal; white-space: pre-wrap;&quot;&gt;&lt;code&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; &lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot; initialize=&quot;init()&quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:Script&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;![CDATA[&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;import com.google.maps.Map; import com.google.maps.MapEvent;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;import com.google.maps.MapType;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;import com.google.maps.controls.*;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;import com.google.maps.LatLng;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;private var gMap:Map;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;//Init function&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;private function init():void { &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;gMap = new Map();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;gMap.key = &quot;{}&quot;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp;gMap.addEventListener(MapEvent.MAP_READY, mapReadyHandler); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mapContainer.addChild(gMap);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;//&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;private function mapReadyHandler(e:MapEvent):void {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;gMap.setCenter(new LatLng(40.718119, -73.995667), 13, MapType.HYBRID_MAP_TYPE); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gMap.setSize(new Point(mapContainer.width, mapContainer.height)); &amp;nbsp;gMap.setZoom(14,false);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;gMap.addControl(new PositionControl());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;gMap.addControl(new ZoomControl());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span style=&quot;color: red;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;gMap.addControl(new MapTypeControl());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;} ]]&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;/mx:Script&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;mx:UIComponent id=&quot;mapContainer&quot; width=&quot;60%&quot; height=&quot;80%&quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: red;&quot;&gt;&amp;lt;/mx:Application&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://aboukalane.blogspot.com/feeds/7031923025709945935/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aboukalane.blogspot.com/2009/09/your-first-google-map-on-flex.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/7031923025709945935'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/7031923025709945935'/><link rel='alternate' type='text/html' href='http://aboukalane.blogspot.com/2009/09/your-first-google-map-on-flex.html' title='&lt;b&gt;&lt;font color=&quot;blue&quot;&gt;your first google map on Flex&lt;/font&gt;&lt;/b&gt;'/><author><name>Anass Boukalane</name><uri>http://www.blogger.com/profile/16556828831189033073</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVoEpeQ7RRt9QoDSz9_B4NUEee0neBxVDTZyjWrA0MM1wGVdKB41JmtTo5ey8qk9ricJ7ZNInEVtCCRso0XIhVJfxHDMBIDWW5-4NnSdici-oHWA3Y-hSua_WaDwdQZDU/s220/IMG_0000_28.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5293931621561625477.post-6775450285439477302</id><published>2009-09-05T09:11:00.000-07:00</published><updated>2009-09-08T05:22:14.796-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Flex"/><title type='text'>Flex and Google Map</title><content type='html'>i will post some samples about how to use GoogleMap in flex&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: 13px; white-space: pre;&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
var gaJsHost = ((&quot;https:&quot; == document.location.protocol) ? &quot;https://ssl.&quot; : &quot;http://www.&quot;);
document.write(unescape(&quot;%3Cscript src=&#39;&quot; + gaJsHost + &quot;google-analytics.com/ga.js&#39; type=&#39;text/javascript&#39;%3E%3C/script%3E&quot;));
&lt;/script&gt; &lt;script type=&quot;text/javascript&quot;&gt;
try {
var pageTracker = _gat._getTracker(&quot;UA-10573090-1&quot;);
pageTracker._trackPageview();
} catch(err) {}
&lt;/script&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://aboukalane.blogspot.com/feeds/6775450285439477302/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aboukalane.blogspot.com/2009/09/flex-and-google-map.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/6775450285439477302'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5293931621561625477/posts/default/6775450285439477302'/><link rel='alternate' type='text/html' href='http://aboukalane.blogspot.com/2009/09/flex-and-google-map.html' title='&lt;b&gt;&lt;font color=&quot;blue&quot;&gt;Flex and Google Map&lt;/font&gt;&lt;/b&gt;'/><author><name>Anass Boukalane</name><uri>http://www.blogger.com/profile/16556828831189033073</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVoEpeQ7RRt9QoDSz9_B4NUEee0neBxVDTZyjWrA0MM1wGVdKB41JmtTo5ey8qk9ricJ7ZNInEVtCCRso0XIhVJfxHDMBIDWW5-4NnSdici-oHWA3Y-hSua_WaDwdQZDU/s220/IMG_0000_28.jpg'/></author><thr:total>0</thr:total></entry></feed>