Unlocking More Users, with Tablets and Games

Posted by Purnima Kochikar, Director of Business Development, Games & Applications



Last week, we unveiled a number of new things in the world of Android. And while we already showcased the new tools available at your disposal in Android 4.3, we also unveiled a new Nexus 7 tablet, as well as the Google Play Games app, both of which represent opportunities to take advantage of a growing number of users.



Nexus 7 and the Android tablet revolution



If you’re a developer optimizing your app for Android tablets, no doubt you’re familiar with the original Nexus 7. It was Google’s statement on what a great Android tablet experience should look like, and since then, the Android tablet ecosystem has come a long way. There have already been more than 70 million activations of Android tablets, with more than 1 in 2 tablets sold today running Android. We’re starting to see with Android tablets what could be the hockey stick growth all of us experienced a couple of years ago with Android smartphones, and we hope that the new Nexus 7 continues to fuel this growth even further.



Most top developers on Android have already prepared their applications for this wave of new Android tablet users, including many of the essentials, like the New York Times, Zappos, Evernote, Flipboard, Pinterest and more. To help users find your tablet-designed apps more easily on Google Play, you can now choose to only see apps designed for tablets in the top lists. There are also over 50 new collections, which highlight outstanding tablet apps.



To take advantage of the Android tablet revolution, check out our Tablet App Quality Checklist, which has tips and techniques on how to deliver a great app experience for tablet users. It details all of the key things you need to do to optimize your app for tablets, like taking advantage of the extra screen real estate and adjusting font sizes and touch targets, to things you can do on the distribution side, like declaring support for tablet screens and showcasing your tablet UI on Google Play by uploading tablet-specific screenshots. Optimizing your app for Android tablets will unlock a whole new group of users, like those who are about to receive their new Nexus 7 tablets.





Taking your game to the next level



The Android games category on Google Play is on fire; in fact, the vast majority of top mobile game developers are building Android tablet games, and most new titles launch immediately on Android. To help game developers take advantage of the next generation of games, at Google I/O in May, we introduced Google Play game services, our gaming platform for Android, iOS, and the web. By building on Google’s strengths in mobile and cloud services, Google Play game services allows game developers to focus on what they’re good at: creating great gaming experiences for their users.



Turbocharging that growth even more, on Wednesday we introduced the Google Play Games app, which brings your friends together with the games you love, where you can invite a friend and start challenging gamers around the world, compete for top achievements, and race to the top of the leaderboard.



Since the launch at Google I/O, just over two months ago, over one thousand games have added Google Play game services, with millions of users enjoying features like leaderboards and multiplayer inside of the games they love. Some of those early developers using Google Play game services are reporting incredible upticks in vital engagement metrics; for instance, Concrete Software is seeing session length up 15%, and Glu is reporting a 40% increase in 7-day user retention.



Here are a few things you can do to take your game to the next level with Google Play:



  • Integrate with Play Games using achievements and leaderboards to activate your players.

  • Add real-time multiplayer to competitive and cooperative games and increase engagement.

  • Use Play Games branding guidelines and create rich visuals that bolster your presence in the Google Play Games app.



Whether it be getting your app ready for the wave of new Android tablets that are lighting up each day, or opening up a whole new set of features for your users with Google Play game services, a great Android experience starts with a great app or game. That’s why we’re working hard to help provide you with the tools and features needed to create those great experiences for your users, and to help you reach as many of them as possible in the process, with Google Play.



Android Emulator error libGL.so: cannot open shared object file: No such file or directory

If you run Android Emulator with the error of "libGL.so: cannot open shared object file: No such file or directory", you have to make link for libGL.so.

My machine run Ubuntu 12.04. The following is my solution to fix it. (assume libGL is installed in somewhere in your system)

- Locate your installed libGL:
$locate libGL

- make link to installed libGL.so
$sudo ln -s /usr/lib/i386-linux-gnu/libGLU.so.1 /usr/lib/libGL.so

locate and ln libGL.so


Android Emulator now support Google Play services SDK

As in the beginning of the year "Google Play services is not supported on the Android emulator". With Android SDK updated, Google Play services SDK is now supported in Android Emulator with AVD that runs the Google APIs platform based on Android 4.2.2 or higher.

If you want to test your app on the emulator, run Android SDK Manager, expand the directory for Android 4.2.2 (API 17) or a higher version, select Google APIs, and install it. Then create a new AVD with Google APIs as the platform target.

Note: Only Android 4.2.2 and higher versions of the Google APIs platform include Google Play services.

Reference: Setup Google Play Services SDK

Remark: Unfortunately, I cannot run my Google Maps Android API V2 examples on Emulator caused by "Google Play services out of date..."!

Make app with translucent background

To make your app with translucent background, apply the following code in your theme.

<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>


For example, modify /res/values/styles.xml (the auto-generated style):
<resources>

<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->

<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>

</style>

</resources>

Translucent background

Intro to ActionBarCompat Support Library

DevBytes: Intro to ActionBarCompat Support Library

An introduction to this new support library, which allows you to add a compatible Action Bar to your application, targeting Android v2.1 or newer. This DevByte covers integrating the library, from adding it as a dependency to modifying your resources and code. For more information you can visit - http://developer.android.com/guide/topics/ui/actionbar.html

Google Cast Developer Preview

Google Cast is a screen-sharing technology that lets a user send and control content like video from a small computing device like a phone, tablet, or laptop to a large display device like a television.

A sender application running on the sender device uses the Google Cast API appropriate to its operating system to discover and transmit to the receiver application running on the receiver device. You can use the sender APIs to enable your Android, iOS, or Chrome app to send content to a large display.

The receiver device runs a scaled-down Chrome browser with a receiver application that receives data over Internet Protocol and transmits it to the television via HDMI. The receiver API lets you customize the messaging between the sender and receiver applications for authentication and other scenarios.

Google Cast Developer Preview lets you experiment with this unique second-screen functionality in your applications.

You can develop sender applications for Android, iOS, and Chrome which "cast" their content to a receiver device connected to a large display (television), and you can develop a receiver app that extends the default receiver functionality.

Note: You may not publicly distribute or ship your Google Cast application without written permission from Google, per the terms of service described on the Downloads page.

The APIs in this preview release are subject to change. This preview supports the same three platforms that are intended for the released product: Android, iOS, and Chrome. If you are developing a Chrome application, Google will need to whitelist your website for development. This process usually takes only a few days.

Visit Google Cast Developers Site

Bluetooth Low Energy API in Android 4.3

With Android 4.3 comes the Bluetooth Low Energy API. In this DevBytes Fred Chung gives a brief overview of the technology, and how Android supports it at the platform level.


Google Chromecast HDMI Streaming Media Player available at Amazon, $35.00 only


  • Stream online video, music and more to your TV using your smartphone, tablet, or laptop
  • Supports Netflix, YouTube, Google Play, as well as anything on the web through Chrome browser
  • Works with Android, iOS, Chrome for Mac, and Chrome for Windows
  • Easy setup: Plug into any HDTV and connect to your home WiFi network
  • Box includes Chromecast, HDMI extender, USB power cable, and power adapter


Introducing Android 4.3, a sweeter Jelly Bean

Today we’re releasing Android 4.3 — an upgrade to Jelly Bean that introduces a number of new features, including restricted profiles. Android 4.3 also adds Bluetooth Smart support (a.k.a Bluetooth Low-Energy); the latest in 3D graphics through OpenGL ES 3.0; and more.

Restricted profiles for tablets
Lightweight and portable, tablets are perfect for sharing with others. Last October we added support for multiple users. Each person has a separate space and can freely customize the tablet experience, from lockscreen to wallpaper, apps and folders.

In Android 4.3, we're introducing restricted profiles, which let you manage per-user access to apps and content. Restricted profiles can be used in any number of situations. For example, restricted profiles enable parental controls, so certain family members are prevented from accessing mature content. Alternately, retail stores can use tablets as kiosks that show product information, or shops can use tablets as point of sale systems, all while limiting access to apps.

To set up restricted profiles on your tablet, go to the Users section under Settings. Learn more.



Bluetooth Smart support (a.k.a. Bluetooth Low-Energy)
Fitness sensors and other devices that use Bluetooth Smart technology open the door for a whole new class of mobile applications. Bluetooth Smart minimizes power usage while measuring and transmitting data, making both sensors and the phones or tablets connected to them more battery-efficient.

With Android 4.3, Nexus 4 can now connect to Bluetooth Smart sensors. Runtastic and many other developers are making Android apps compatible with these sensors.


Accelerated 3D graphics with OpenGL ES 3.0
Devices like the new Nexus 7 support OpenGL ES 3.0, the latest industry standard for accelerated 3D graphics. This brings photorealism to a whole new level in the games you're playing: blades of grass on the soccer field come alive, asphalt on the street looks real as you screech by, stubble on a villains' face almost pokes out of the screen. And with sophisticated effects like self-shadows, that villain looks even more menacing, casting a shadow on himself.


Dial pad autocomplete
With Android 4.3 we’ve introduced a new autocomplete feature in the dial pad. Just start touching numbers or letters and the dial pad will suggest phone numbers or names. To turn on this feature, open your phone app settings and enable “Dial pad autocomplete”.

Improved support for Hebrew, Arabic, Hindi, and more
We’ve made major progress on enabling right-to-left layouts across the platform user interface: dialer, home and lock screens, settings, and more. This work builds on the support that we introduced for right-to-left layouts for Hebrew and Arabic speakers in Android 4.2. We’ve also added support for Hindi, Afrikaans, Amharic, Swahili, and Zulu.


There’s more to Android 4.3 than we can fit in this post, so for a detailed list of changes, click here.

Android 4.3 is now rolling out now to Nexus devices, and will be available on the new Nexus 7 and Google Play edition devices soon. Let us know what you think on our Google+ page for Android.

Posted by Dave Burke and Gabe Cohen, Android Platform team

Android 4.3 announced and Developer Tools updated

Android 4.3 of Jelly Bean announced, includes great new features for users and developers. Android 4.3 powers the new Nexus 7 tablet and it’s rolling out now as an update to Nexus 4, Nexus 7, Nexus 10, and Galaxy Nexus HSPA+ devices across the world.

For developers, Android 4.3 includes the latest performance enhancements to keep your apps fast, smooth, and efficient, together with new APIs and capabilities to use in your apps.

Know more: http://android-developers.blogspot.hk/2013/07/android-43-and-updated-developer-tools.html

From TVs to tablets: Everything you love, across all your screens

When I was growing up, my family had a single screen we huddled around every day: the television set in the living room. Nowadays, we “huddle” around multiple screens—laptops, smartphones and tablets—using them almost interchangeably as we navigate through our day. In a world of ubiquitous computing, life would be a lot simpler if we didn’t have to learn new behaviors and interfaces each time we switched screens—if we could have one consistent, intuitive experience no matter where we are or what we’re doing. Today, with the launch of Chromecast and the new Nexus 7 tablet, it’s even more effortless to enjoy content you care about—whether it’s video, music, movies, games—wherever you are, across your devices. Introducing ChromecastTo help make it easy to bring your favorite online entertainment to the biggest screen in your house—the TV—we’re introducing Chromecast. Chromecast is a small and affordable ($35) device that you simply plug in to your high-definition (HD) TV and it allows you to use your phone, tablet or laptop to "cast" online content to your TV screen. It works with Netflix, YouTube, Google Play Movies & TV, and Google Play Music, with more apps like Pandora coming soon. With Chromecast, we wanted to create an easy solution that works for everyone, for every TV in the house.


Remote-freeOnce your Chromecast is set up, you can use your phone, tablet or laptop to browse and cast content to your TV, play and pause, control the volume, and more. But unlike other streaming solutions, you can still multitask—send emails or surf the web—while enjoying what’s on the TV screen. It works across platforms—Android tablets and smartphones, iPhones, iPads, Chrome for Mac and Windows (more to come), so your personal device is also now your remote control. Cast the web to your TVIn addition to apps like Netflix, you can use Chromecast to bring a broad range of content available on the web to your big screen, thanks to a new feature in the Chrome browser that allows you to project any browser tab to your TV. From sharing your family photos to enjoying a video clip from your favorite news site, it’s as simple as pressing a button. This feature is launching in beta, but we’re excited for people to try it out and give us their feedback.

 
Google Cast SDK preview for developersTo ensure a great Chromecast experience over time, we've built Google Cast, a technology that enables developers to build consistent, intuitive multi-screen experiences across mobile devices and TVs. Today, we’re launching a preview version of Google Cast with more information for developers on our Google Developers blog. A handful of early developers are already working on enabling Google Cast technology in their apps, so more supported apps are coming soon. And while the Chromecast device is the first instantiation of Google Cast, we expect the technology to be embedded in a range of hardware from our partners in the future.


The new Nexus 7—the sharpest 7” tablet screen everTogether with ASUS, we took what you loved about the original Nexus 7 and made it even better. The first thing you’ll notice is the sharpness of the screen: the 323 pixels packed into every inch of the screen makes it the world's highest-resolution 7-inch tablet. It’s lighter than ever, with more than nine hours of HD video playback and 10 hours of web browsing or reading. Nexus 7 now features stereo speakers and virtual surround sound from Fraunhofer (the inventors of the MP3 format), giving you rich and immersive audio. Android 4.3—a sweeter Jelly BeanNexus 7 is the first device to ship with Android 4.3, the newest version of Android. Tablets are perfect for sharing with others, so in Android 4.3, we're introducing restricted profiles, which let you limit access to apps and content. For example, restricted profiles enable parental controls, so certain family members are prevented from accessing mature content. Likewise, retail stores can use tablets to show off product information, and shops can use tablets as point of sale systems. Android 4.3 also now supports Bluetooth Smart technology, opening the door to mobile apps that connect to new devices like fitness sensors. Android 4.3 is rolling out to Nexus devices starting today. Ready to PlayThe new Google Play Games app brings your friends together with the games you love, where you can invite a friend and start challenging gamers around the world, compete for top achievements, and race to the top of the leaderboard. You can also enjoy the world’s largest collection of eBooks, listen to millions of music tracks and immerse yourself in thousands of movies, TV shows, magazines and apps on Google Play. Plus, Nexus 7 comes loaded with your favorite Google apps, like Chrome, Maps, YouTube, Gmail and Google Now.

 
How to get Chromecast and the new Nexus 7Starting today, the Chromecast device is available for $35 on Google Play, Amazon.com and BestBuy.com. It will be available in Best Buy stores across the U.S. starting July 28. For a limited time, you also get three months of Netflix included. More info available in Google Play. Nexus 7 starts at $229, and is available in the U.S. beginning July 30 (with more countries coming soon!). Buy Nexus 7 online on Google Play, or check it out at Best Buy, Gamestop, Walmart, Staples, Office Max, Office Depot, Amazon, Home Shopping Network, Radio Shack, J&R and B&H Photo. Nexus 7 (LTE) is coming soon with support for T-Mobile and Verizon in the coming weeks. Learn more on our Nexus site.

Android 4.3 and Updated Developer Tools

Posted by Dave Burke, Engineering Director, Android Platform


Today in San Francisco we announced Android 4.3, a sweeter version of Jelly Bean that includes great new features for users and developers. Android 4.3 powers the new Nexus 7 tablet that's coming soon to Google Play and retail outlets, and it’s rolling out now as an update to Nexus 4, Nexus 7, Nexus 10, and Galaxy Nexus HSPA+ devices across the world.



For developers, Android 4.3 includes the latest performance enhancements to keep your apps fast, smooth, and efficient, together with new APIs and capabilities to use in your apps. Here's a taste of what's new:




  • OpenGL ES 3.0 — Game developers can now take advantage of OpenGL ES 3.0 and EGL extensions as standard features of Android, with access from either framework or native APIs.

  • Bluetooth Smart — Now your apps can communicate with the many types of low-power Bluetooth Smart devices and sensors available today, to provide new features for fitness, medical, location, proximity, and more.

  • Restricted profiles — Tablet owners can create restricted profiles to limit access to apps, for family, friends, kiosks, and more. Your app can offer various types of restrictions to let tablet owners control its capabilities in each profile.

  • New media capabilities — A modular DRM framework enables media application developers to more easily integrate DRM into their own streaming protocols such as MPEG DASH. Apps can also access a built-in VP8 encoder from framework or native APIs for high-quality video capture.

  • Notification access — Your apps can now access and interact with the stream of status bar notifications as they are posted. You can display them in any way you want, including routing them to nearby Bluetooth devices, and you can update and dismiss notifications as needed.

  • Improved profiling tools — New tags in the Systrace tool and on-screen GPU profiling give you new ways to build great performance into your app.



Check out the Android 4.3 platform highlights for a complete overview of what’s new for developers. To read more about the new APIs and how to use them, take a look at the API Overview or watch the new DevBytes videos.



Along with the new Android 4.3 platform we’re releasing an update to the Android NDK (r9). The new NDK gives you native access to the OpenGL ES 3.0 APIs and other stable APIs in Android 4.3, so if you use high-performance graphics in your games or apps, make sure to check it out.



Last, we’ve updated the Android Support Library (r18) with several key APIs to help you build great apps with broad compatibility. Most important, we've added an Action Bar API to let you build this essential Android design pattern into your app with compatibility back to Android 2.1. For apps targeting RTL languages, there's a new BidiFormatter utility you can use to manage RTL strings with compatibility back to Android 2.1. Also, watch for a new RenderScript feature coming soon that will let you take advantage of hardware-accelerated computation with compatibility back to Android 2.2.



You can get started developing and testing on Android 4.3 right away, in Android Studio or in ADT/Ant. You can download the Android 4.3 Platform (API level 18), as well as the SDK Tools, Platform Tools, and Support Library from the Android SDK Manager.

Determine event source in event listener

Last example demonstrate a "Simple example of Button and OnClickListener", with individual OnClickListener for each View. Alternatively, we can have a common OnClickListener for more than one View, then determine event source in event listener, and perform the correspond operation accordingly.

Determine event source in event listener


package com.example.androidbutton;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

LinearLayout myBackGround = (LinearLayout)findViewById(R.id.mybackground);
myBackGround.setOnClickListener(this);

TextView myWeb = (TextView)findViewById(R.id.myweb);
myWeb.setOnClickListener(this);

Button button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener(this);

Button button2 = (Button)findViewById(R.id.button2);
button2.setOnClickListener(this);

ImageView myImage =(ImageView)findViewById(R.id.myimage);
myImage.setOnClickListener(this);
}

@Override
public void onClick(View v) {
if(v.getClass() == TextView.class){
Toast.makeText(getApplicationContext(),
"It's TextView:\n" + ((TextView)v).getText(),
Toast.LENGTH_SHORT).show();
}else if(v.getClass() == Button.class){
Toast.makeText(getApplicationContext(),
"It's Button:\n" + ((Button)v).getText(),
Toast.LENGTH_SHORT).show();
}else if(v.getClass() == ImageView.class){
Toast.makeText(getApplicationContext(),
"It's ImageView:",
Toast.LENGTH_SHORT).show();

//setRotation require API Level 11
float rot = ((ImageView)v).getRotation() + 90;
((ImageView)v).setRotation(rot);

}else{
Toast.makeText(getApplicationContext(),
"Background clicked",
Toast.LENGTH_SHORT).show();
}
}

}


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity"
android:id="@+id/mybackground" >

<TextView
android:id="@+id/myweb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android-er.blogspot.com" />

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 1"/>
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 2"/>
<ImageView
android:id="@+id/myimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"/>

</LinearLayout>


Simple example of Button and OnClickListener

Basic example of Button and OnClickListener to handle button click:

package com.example.androidbutton;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button button1 = (Button)findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View arg0) {
Toast.makeText(getApplicationContext(),
"Button 1 clicked",
Toast.LENGTH_LONG).show();
}});

Button button2 = (Button)findViewById(R.id.button2);
button2.setOnClickListener(button2OnClickListener);
}

OnClickListener button2OnClickListener =
new OnClickListener(){

@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),
"Button 2 clicked",
Toast.LENGTH_LONG).show();
}};

}


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android-er.blogspot.com" />

<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 1"/>
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 2"/>

</LinearLayout>

Simple example of Button


Next:
- Determine event source in event listener

OpenWeatherMap - free weather data and forecast API

The OpenWeatherMap service provides free weather data and forecast API suitable for any cartographic services like web and smartphones applications. Ideology is inspired by OpenStreetMap and Wikipedia that make information free and available for everybody. OpenWeatherMap provides wide range of weather data such as map with current weather, week forecast, precipitation, wind, clouds, data from weather Stations and many others. Weather data is received from global Meteorological broadcast services and more than 40 000 weather stations.

OpenWeatherMap

Gradle Beyond the Basics - read online for FREE

Gradle Beyond the Basics

If you’re familiar with Gradle’s basics elements—possibly through the author’s previous O’Reilly book, Building and Testing with Gradle—this more advanced guide provides the recipes, techniques, and syntax to help you master this build automation tool. With clear, concise explanations and lots of ready-to-use code examples, you’ll explore four discrete areas of Gradle functionality: file operations, custom Gradle plugins, build lifecycle hooks, and dependency management.

Learn how to use Gradle’s rich set of APIs and Groovy-based Domain Specific Language to customize build software that actually conforms to your product. By using the techniques in this book, you’ll be able to write domain-specific builds that support every other line of code your team creates.




  • Examine Gradle’s file API, including copy tasks, pattern matching, content filtering, and the FileCollection interface
  • Understand the process for building and packaging a custom Gradle plug-in
  • Manage build complexity with hook methods and Gradle’s rule feature
  • Learn how Gradle handles dependency management natively and through customization
  • Explore Gradle’s core plug-ins as well as key examples from the Gradle community

read online: http://chimera.labs.oreilly.com/books/1234000001741

Require more memory for App to run

To request more memory for App to run, you can specify android:largeHeap="true" in <application>. android:largeHeap specify Whether your application's processes should be created with a large Dalvik heap.

reference: http://developer.android.com/guide/topics/manifest/application-element.html#largeHeap

Making Beautiful Android App Icons

Posted by Roman Nurik, Android Developer Relations



For most users, the launcher icon (sometimes referred to as the app icon) is the first impression of your app. As higher density screens on both phones and tablets gain popularity, it's important to make sure your launcher icon is crisp and high quality. To do this, make sure you’re including XHDPI (320dpi) and XXHDPI (480dpi) versions of the icon in your app.

In addition to the current launcher icon guidelines, please also refer to these additional important guidelines when creating your icons:

  • Launcher icons are 48dp square and should be provided for MDPI, HDPI, XHDPI, and XXHDPI densities—at the very least XHDPI and XXHDPI.

  • The 512px Google Play listing icon should have the same content as the launcher icon, except for minor additional badging.

  • Launcher icons should be designed specifically for Android. As per the Pure Android design guidelines, avoid mimicking visual elements and styles from other platforms.

  • Launcher icons should be three-dimensional, front view, with a slight perspective as if viewed from above, so that users perceive some depth.

  • Launcher icons should have a distinct silhouette, meaning that you should avoid simple square/circle icons and instead opt for unique shapes.

  • Launcher icons should be simple at the macro level but still detailed at the micro level (e.g. include subtle edge effects, gradients and textures).

  • Launcher icons should employ lightweight background protection such as a subtle drop shadow, but it should not be too dark or visually prominent.

  • Launcher icons should include between 0dp and 3dp of padding. Vary the padding for optical alignment and weight normalization purposes (e.g. thinner icons can use smaller padding and thicker icons can use less padding for a more consistent icon mass across icons).

Note that tablets and other large screen devices request a launcher icon that is one density size larger than the device's actual density, so you should provide your launcher icon at the highest density possible. For example, if a tablet has an XHDPI screen, it will request the XXHDPI version of the launcher icon.

Android Studio 0.2.1 Released with Gradle fix

Example to specify View with half width




<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textStyle="bold|italic"
android:layout_gravity="center_horizontal" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="http://arteluzevida.blogspot.com/"
android:background="#D0D0D0" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Button" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="<Space> require API 14"
android:background="#B0B0B0" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Use weightSum and layout_weight"
android:background="#909090" />
</LinearLayout>

</LinearLayout>


50 Android Hacks



50 Android Hacks

The best programming techniques are often the shortest and simplest—the hacks. In this compact and infinitely useful book, Android expert Carlos Sessa delivers 50 hacks that will save you time, stretch your skills, and maybe even make you smile.

About this Book

Hacks. Clever programming techniques to solve thorny little problems. Ten lines of code that save you two days of work. The little gems you learn from the old guy in the next cube or from the geniuses on Stack Overflow. That's just what you'll find in this compact and useful book.
The name 50 Android Hacks says it all. Ranging from the mundane to the spectacular, each self-contained, fully illustrated hack is just a couple of pages long and includes annotated source code. These practical techniques are organized into twelve collections covering layout, animations, patterns, and more.

What's Inside
  • Hack 3 Creating a custom ViewGroup
  • Hack 8 Slideshow using the Ken Burns effect
  • Hack 20 The Model-View-Presenter pattern
  • Hack 23 The SyncAdapter pattern
  • Hack 31 Aspect-oriented programming in Android
  • Hack 34 Using Scala inside Android
  • Hack 43 Batching database operations
  • Plus 43 more hacks!
Most hacks work with Android 2.x and greater. Version-specific hacks are clearly marked.
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Author


Carlos Sessa is a passionate professional Android developer. He's active on Stack Overflow and is an avid hack collector.

Table of Contents
  1. Working your way around layouts
  2. Creating cool animations
  3. View tips and tricks
  4. Tools
  5. Patterns
  6. Working with lists and adapters
  7. Useful libraries
  8. Interacting with other languages
  9. Ready-to-use snippets
  10. Beyond database basics
  11. Avoiding fragmentation
  12. Building tools

Apply animation on TextView

Apply animation on TextView


To create animation, create xml file to define animation in /res/anim/ folder, /res/anim/myanimation.xml.
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<scale
android:fromXScale="1.0"
android:toXScale="0.8"
android:fromYScale="1.0"
android:toYScale="1.2"
android:pivotX="50%"
android:pivotY="50%"
android:duration="100"
android:repeatCount="4"
android:repeatMode="reverse" />
</set>


In Java code, create Animation of the anim resource file with AnimationUtils.loadAnimation() method, and start the animation with startAnimation() method of the target view.
package com.example.androidtextview;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import android.app.Activity;

public class MainActivity extends Activity {

Animation myAnimation;
TextView myText;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myText = (TextView)findViewById(R.id.mytext);

myAnimation = AnimationUtils.loadAnimation(this, R.anim.myanimation);

myText.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View arg0) {
myText.startAnimation(myAnimation);
}});
}

}


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textStyle="bold|italic"
android:layout_gravity="center_horizontal" />

<TextView
android:id="@+id/mytext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="http://arteluzevida.blogspot.com/"
android:textStyle="bold"
android:textSize="30sp"
android:textColor="#0000ff" />

</LinearLayout>



Implement auto-running TextView



<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textStyle="bold|italic"
android:layout_gravity="center_horizontal" />

<TextView
android:id="@+id/shadowtext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="http://arteluzevida.blogspot.com/"
android:textStyle="bold"
android:textSize="50sp"
android:textColor="#0000ff"

android:focusable="true"
android:focusableInTouchMode="true"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever" />

</LinearLayout>




Add shadow for TextView, using Java code.


To add shadow on TextView using Java code, call setShadowLayer() method.

package com.example.androidtextview;

import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TextView shadowText = (TextView)findViewById(R.id.shadowtext);
shadowText.setShadowLayer(30, 10, 10, 0xFF303030);

}

}


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textStyle="bold|italic"
android:layout_gravity="center_horizontal" />

<TextView
android:id="@+id/shadowtext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="http://arteluzevida.blogspot.com/"
android:textStyle="bold"
android:textSize="30sp"
android:textColor="#0000ff" />

</LinearLayout>


Related: compare to Add shadow for TextView, using XML.

Add shadow for TextView, using XML.

TextView with shadow

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textStyle="bold|italic"
android:layout_gravity="center_horizontal" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="http://arteluzevida.blogspot.com/"
android:textStyle="bold"
android:textSize="30sp"
android:textColor="#0000ff"
android:shadowColor="#303030"
android:shadowDx="10"
android:shadowDy="10"
android:shadowRadius="30" />

</LinearLayout>


Related: compare with Add shadow for TextView, using Java code.


Example to implement shape of oval with gradient color

shape of oval

To implement shape using "oval", create /res/drawable/myshape.xml to define the shape.
<shape 
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid
android:color="#e0e0e0" />
<stroke
android:width="5dip"
android:color="#505050"/>
<gradient
android:startColor="#FFFF0000"
android:endColor="#800000FF"
android:angle="45"/>
</shape>


Apply the shape on layout background, modify /res/layout/activity_main.xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textStyle="bold|italic"
android:layout_gravity="center_horizontal"
android:background="#B0B0B0" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:gravity="center_horizontal"
android:background="@drawable/myshape"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="http://arteluzevida.blogspot.com/"
android:textStyle="bold"
android:textColor="@android:color/black"
android:gravity="center"
android:background="@drawable/myshape" />

</LinearLayout>


Android Security: Attacks and Defenses



Android Security: Attacks and Defenses is for anyone interested in learning about the strengths and weaknesses of the Android platform from a security perspective. Starting with an introduction to Android OS architecture and application programming, it will help readers get up to speed on the basics of the Android platform and its security issues.

Explaining the Android security model and architecture, the book describes Android permissions, including Manifest permissions, to help readers analyze applications and understand permission requirements. It also rates the Android permissions based on security implications and covers JEB Decompiler.

The authors describe how to write Android bots in JAVA and how to use reversing tools to decompile any Android application. They also cover the Android file system, including import directories and files, so readers can perform basic forensic analysis on file system and SD cards. The book includes access to a wealth of resources on its website: www.androidinsecurity.com. It explains how to crack SecureApp.apk discussed in the text and also makes the application available on its site.

The book includes coverage of advanced topics such as reverse engineering and forensics, mobile device pen-testing methodology, malware analysis, secure coding, and hardening guidelines for Android. It also explains how to analyze security implications for Android mobile devices/applications and incorporate them into enterprise SDLC processes.

The book’s site includes a resource section where readers can access downloads for applications, tools created by users, and sample applications created by the authors under the Resource section. Readers can easily download the files and use them in conjunction with the text, wherever needed. Visit www.androidinsecurity.com for more information.

Android Studio upgrade 0.2.0

download updated Android Studio and installation instruction: http://developer.android.com/sdk/installing/studio.html

Graphical Layout Editor of ADT

ADT provides many features to allow you to design and build your application's user interface. Many of these features are in the graphical layout editor, which you can access by opening one of your application's XML layout files in Eclipse.

Graphical Layout Editor of ADT


Know more: Android Developer Tools - Graphical Layout Editor

Learn about the new Google Maps app for Android

Implement custom shape for background

custom shape for background


To implement our custom shape, create xml file to define our shape in res/drawable/ folder, /res/drawable/myshape.xml.
<shape 
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="#e0e0e0" />
<stroke
android:width="5dip"
android:color="#505050"/>
</shape>


Apply the shape on view with android:background="@drawable/myshape" in layout xml file.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textStyle="bold|italic"
android:layout_gravity="center_horizontal"
android:background="#B0B0B0" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:gravity="center_horizontal"
android:background="@drawable/myshape"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="http://arteluzevida.blogspot.com/"
android:textStyle="bold"
android:textColor="@android:color/black"
android:gravity="center"
android:background="@drawable/myshape" />

</LinearLayout>


Implement vertical TextView by calling setRotation()

API Level 11 provide setRotation(float rotation) method to rotate a View. We can call the method of TextView object to make it display in vertical.

vertical TextView

Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:textStyle="bold|italic"
android:layout_gravity="center_horizontal"
android:background="#B0B0B0" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">

<TextView
android:id="@+id/verticaltextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android-er"
android:textStyle="bold"
android:textColor="#00FF00"
android:layout_gravity="center"
android:background="#808080" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="http://arteluzevida.blogspot.com/"
android:textStyle="bold"
android:textColor="@android:color/white"
android:gravity="center"
android:background="#505050" />

</LinearLayout>

</LinearLayout>


Java code, call setRotation() to display the TextView (verticalTextView) in vertical.
package com.example.androidtextview;

import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;

public class MainActivity extends Activity {

TextView verticalTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

verticalTextView = (TextView)findViewById(R.id.verticaltextview);
verticalTextView.setRotation(90);
}


}


remark: Have to modify AndroidManifest.xml to set android:minSdkVersion="11" or higher.

Mid Year 2013 Android Developer Survey

Posted by Reto Meier, Android Developer Relations Tech Lead



The 2013 mid-year Android Developer Survey is now open!



Last year more than 5,000 of you shared your Android Development experiences and challenges with us, and your responses directly influenced our choices and priorities for building things like Android Studio, the new Google Play Publishing Console, and the Google Play services.





We in the Android Developer Relations team are passionate about making Android app development a great experience, so we're once again asking all of you involved in developing Android apps - engineers, designers, product managers, and distribution and support folks - to let us know what you think.



We want to better understand the challenges you face when planning, designing, writing, distributing, and monetizing your Android apps, so we've put together this brief (15-20min) survey that will help us create better tools and resources for you.



In an effort to get a better representation of developers from around the world the survey is available in the following languages:



Last year you told us you'd like a way to give us general written feedback, so to facilitate this while keeping the survey short and simple, we've included a link at the end of the survey that will let you send us as much direct feedback as you care to, completely anonymously.



Of course, you can always send us your thoughts, questions, suggestions, and complaints any time by posting to us (publicly or privately) on Google+ at +Android Developers or using the hash tag #AndroidDev.



As always, we're looking forward to hearing your thoughts!

GPS / Database ANDROID Programming


This book is a step-by-step guide for developing 'gps', a full-fledged Android app. It also can be used as an intro book on Android programming. 

The gps app:
• locates the user's position on the map
• e-mails the location in a URL form that positions the location on the Google Maps Web page
• inserts the current location of the user into the SQLite database
• retrieves locations from the database and places them in a list view. The user then chooses to view locations from the list on the map.
• allows the user to tap on the screen to place markers and find the latitude, longitude pair of the point pressed
• translates the name of a city or place to latitude, longitude and marks the location on the map

Topics covered are:
• Basics of the Eclipse IDE 
• XML and Java Programming 
• Screen layouts
• Global Positioning System (GPS)
• Google Maps
• SQLite Database development
• Marker and Overlays design
• App installation on the smartphone device

The book Includes complete source code commentary and a companion site for downloading the .java, .xml and .png files and the gps.apk.