Laman

Sunday, February 27, 2011

Heading for GDC

[This post is by Chris Pruett, who writes regularly about games here, and is obviously pretty cranked about this conference. — Tim Bray]

Android will descend in force upon the Game Developers Conference in San Francisco this week; we’re offering a full day packed with sessions covering everything you need to know to build games on Android.

From 10 AM to 5 PM on Tuesday the 1st, North Hall Room 121 will be ground zero for Android Developer Day, with five engineering-focused sessions on everything from compatibility to native audio and graphics. Here's a quick overview; there’s more on the Game Developer Conference site:

  • Building Aggressively Compatible Android Games — Chris Pruett

  • C++ On Android Just Got Better: The New NDK — Daniel Galpin and Ian Ni-Lewis

  • OpenGL ES 2.0 on Android: Building Google Body — Nico Weber

  • Android Native Audio — Glenn Kasten and Jean-Michel Trivi

  • Evading Pirates and Stopping Vampires Using License Server, In App Billing, and AppEngine — Daniel Galpin and Trevor Johns

Our crack team of engineers and advocates spend their nights devising new ways to bring high-end game content to Android, and a full day of sessions just wasn't enough to appease them. So in addition, you can find incisive Android insight in other tracks:

Finally, you can visit us in the Google booth on the GDC Expo floor; stop by, fondle the latest devices, and check out the awesome games that are already running on them. We're foaming at the mouth with excitement about the Game Developers Conference next week, and you should be too.

Hope to see you there!

READ MORE - Heading for GDC

Saturday, February 26, 2011

IOException When uploading a apk

I got a strange exception when I try to upload a apk. The exception looks like this,


Failed to upload xxxxxxxx.apk on device 'emulator-5554'
java.io.IOException: Unable to upload file: timeout


After some googling I fount the solution. I need to increase the ADB connection time-out.

The way to increase is,


Window->Preferences->Android->DDMS->ADB connection time-out


By default, the value is 5000, just increase to the sufficient amount.
READ MORE - IOException When uploading a apk

Android SDK cannot detect JDK

Normally I develop Android on Linux machine, and just tried to install the new version of Android SDK on my Windows 7 machine today. I download the exe version of Android SDK, installer_r10-windows.exe. And run it, it's complained by Android SDK Tools Setup that Java SE Development Kit not found. No matter how I config my Windows 7 and JDK!!!

Android SDK cannot detect JDK

Finally I found out the solution:
- Press Back button on the error page
- Press Next again.
- OK !!!
READ MORE - Android SDK cannot detect JDK

Friday, February 25, 2011

Get Network Info

We can get all network info by calling getAllNetworkInfo() method of ConnectivityManager object.

Get All Network Info

AndroidNetworkInfo.java
package com.exercise.AndroidNetworkInfo;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class AndroidNetworkInfo extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ConnectivityManager connectivityManager
= (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] networkInfo
= connectivityManager.getAllNetworkInfo();

List<String> listNetworkInfo = new ArrayList<String>();
for(int i=0; i<networkInfo.length; i++){
listNetworkInfo.add(networkInfo[i].toString());
}

setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
listNetworkInfo));
getListView().setTextFilterEnabled(true);
}
}


Modify AndroidManifest.xml to grant permission to access network state
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exercise.AndroidNetworkInfo"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="4" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".AndroidNetworkInfo"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>


Download the files.

READ MORE - Get Network Info

Necessitas: port of Qt on Android

Necessitas is the codename for the port of Qt on the Android Operating System and of the user-friendly Qt Creator Integration with Android,

This project provides you Qt for the Android Operating System, and a first-class citizen IDE letting you manage, develop, deploy, run & debug your Qt Applications on Android Devices.

To see more, you can click here to get videos of the port, or you can test Qt on your Android Device by installing a demo from the Google Market.

What is Ministro ?

Necessitas is also the Home of Ministro, an Android application which provides a system wide downloader and installer of the LGPL Qt shared libraries. You can find Ministro on the Android Market or as direct download here.



Necessitas Home>>>
READ MORE - Necessitas: port of Qt on Android

Thursday, February 24, 2011

Animation in Honeycomb


[This post is by Chet Haase, an Android engineer who specializes in graphics and animation, and who occasionally posts videos and articles on these topics on his CodeDependent blog at graphics-geek.blogspot.com. — Tim Bray]

One of the new features ushered in with the Honeycomb release is a new animation system, a set of APIs in a whole new package (android.animation) that makes animating objects and properties much easier than it was before.

"But wait!" you blurt out, nearly projecting a mouthful of coffee onto your keyboard while reading this article, "Isn't there already an animation system in Android?"

Animation Prior to Honeycomb

Indeed, Android already has animation capabilities: there are several classes and lots of great functionality in the android.view.animation package. For example, you can move, scale, rotate, and fade Views and combine multiple animations together in an AnimationSet object to coordinate them. You can specify animations in a LayoutAnimationController to get automatically staggered animation start times as a container lays out its child views. And you can use one of the many Interpolator implementations like AccelerateInterpolator and Bounce to get natural, nonlinear timing behavior.

But there are a couple of major pieces of functionality lacking in the previous system.

For one thing, you can animate Views... and that's it. To a great extent, that's okay. The GUI objects in Android are, after all, Views. So as long as you want to move a Button, or a TextView, or a LinearLayout, or any other GUI object, the animations have you covered. But what if you have some custom drawing in your view that you'd like to animate, like the position of a Drawable, or the translucency of its background color? Then you're on your own, because the previous animation system only understands how to manipulate View objects.

The previous animations also have a limited scope: you can move, rotate, scale, and fade a View... and that's it. What about animating the background color of a View? Again, you're on your own, because the previous animations had a hard-coded set of things they were able to do, and you could not make them do anything else.

Finally, the previous animations changed the visual appearance of the target objects... but they didn't actually change the objects themselves. You may have run into this problem. Let's say you want to move a Button from one side of the screen to the other. You can use a TranslateAnimation to do so, and the button will happily glide along to the other side of the screen. And when the animation is done, it will gladly snap back into its original location. So you find the setFillAfter(true) method on Animation and try it again. This time the button stays in place at the location to which it was animated. And you can verify that by clicking on it - Hey! How come the button isn't clicking? The problem is that the animation changes where the button is drawn, but not where the button physically exists within the container. If you want to click on the button, you'll have to click the location that it used to live in. Or, as a more effective solution (and one just a tad more useful to your users), you'll have to write your code to actually change the location of the button in the layout when the animation finishes.

It is for these reasons, among others, that we decided to offer a new animation system in Honeycomb, one built on the idea of "property animation."

Property Animation in Honeycomb

The new animation system in Honeycomb is not specific to Views, is not limited to specific properties on objects, and is not just a visual animation system. Instead, it is a system that is all about animating values over time, and assigning those values to target objects and properties - any target objects and properties. So you can move a View or fade it in. And you can move a Drawable inside a View. And you can animate the background color of a Drawable. In fact, you can animate the values of any data structure; you just tell the animation system how long to run for, how to evaluate between values of a custom type, and what values to animate between, and the system handles the details of calculating the animated values and setting them on the target object.

Since the system is actually changing properties on target objects, the objects themselves are changed, not simply their appearance. So that button you move is actually moved, not just drawn in a different place. You can even click it in its animated location. Go ahead and click it; I dare you.

I'll walk briefly through some of the main classes at work in the new system, showing some sample code when appropriate. But for a more detailed view of how things work, check out the API Demos in the SDK for the new animations. There are many small applications written for the new Animations category (at the top of the list of demos in the application, right before the word App. I like working on animation because it usually comes first in the alphabet).

In fact, here's a quick video showing some of the animation code at work. The video starts off on the home screen of the device, where you can see some of the animation system at work in the transitions between screens. Then the video shows a sampling of some of the API Demos applications, to show the various kinds of things that the new animation system can do. This video was taken straight from the screen of a Honeycomb device, so this is what you should see on your system, once you install API Demos from the SDK.

Animator

Animator is the superclass of the new animation classes, and has some of the common attributes and functionality of the subclasses. The subclasses are ValueAnimator, which is the core timing engine of the system and which we'll see in the next section, and AnimatorSet, which is used to choreograph multiple animators together into a single animation. You do not use Animator directly, but some of the methods and properties of the subclasses are exposed at this superclass level, like the duration, startDelay and listener functionality.

The listeners tend to be important, because sometimes you want to key some action off of the end of an animation, such as removing a view after an animation fading it out is done. To listen for animator lifecycle events, implement the AnimatorListener interface and add your listener to the Animator in question. For example, to perform an action when the animator ends, you could do this:

    anim.addListener(new Animator.AnimatorListener() {
public void onAnimationStart(Animator animation) {}
public void onAnimationEnd(Animator animation) {
// do something when the animation is done
}
public void onAnimationCancel(Animator animation) {}
public void onAnimationRepeat(Animator animation) {}
});

As a convenience, there is an adapter class, AnimatorListenerAdapter, that stubs out these methods so that you only need to override the one(s) that you care about:


anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
// do something when the animation is done
}
});

ValueAnimator

ValueAnimator is the main workhorse of the entire system. It runs the internal timing loop that causes all of a process's animations to calculate and set values and has all of the core functionality that allows it to do this, including the timing details of each animation, information about whether an animation repeats, listeners that receive update events, and the capability of evaluating different types of values (see TypeEvaluator for more on this). There are two pieces to animating properties: calculating the animated values and setting those values on the object and property in question. ValueAnimator takes care of the first part; calculating the values. The ObjectAnimator class, which we'll see next, is responsible for setting those values on target objects.

Most of the time, you will want to use ObjectAnimator, because it makes the whole process of animating values on target objects much easier. But sometimes you may want to use ValueAnimator directly. For example, the object you want to animate may not expose setter functions necessary for the property animation system to work. Or perhaps you want to run a single animation and set several properties from that one animated value. Or maybe you just want a simple timing mechanism. Whatever the case, using ValueAnimator is easy; you just set it up with the animation properties and values that you want and start it. For example, to animate values between 0 and 1 over a half-second, you could do this:

    ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
anim.setDuration(500);
anim.start();

But animations are a bit like the tree in the forest philosophy question ("If a tree falls in the forest and nobody is there to hear it, does it make a sound?"). If you don't actually do anything with the values, does the animation run? Unlike the tree question, this one has an answer: of course it runs. But if you're not doing anything with the values, it might as well not be running. If you started it, chances are you want to do something with the values that it calculates along the way. So you add a listener to it, to listen for updates at each frame. And when you get the callback, you call getAnimatedValue(), which returns an Object, to find out what the current value is.

    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
Float value = (Float) animation.getAnimatedValue();
// do something with value...
}
});

Of course, you don't necessarily always want to animate float values. Maybe you need to animate something that's an integer instead:

    ValueAnimator anim = ValueAnimator.ofInt(0, 100);

or in XML:

    <animator xmlns:android="http://schemas.android.com/apk/res/android"
android:valueFrom="0"
android:valueTo="100"
android:valueType="intType"/>

In fact, maybe you need to animate something entirely different, like a Point, or a Rect, or some custom data structure of your own. The only types that the animation system understands by default are float and int, but that doesn't mean that you're stuck with those two types. You can to use the Object version of the factory method, along with a TypeEvaluator (explained later), to tell the system how to calculate animated values for this unknown type:

    Point p0 = new Point(0, 0);
Point p1 = new Point(100, 200);
ValueAnimator anim = ValueAnimator.ofObject(pointEvaluator, p0, p1);

There are other animation attributes that you can set on a ValueAnimator besides duration, including:

  • setStartDelay(long): This property controls how long the animation waits after a call to start() before it starts playing.
  • setRepeatCount(int) and setRepeatMode(int): These functions control how many times the animation repeats and whether it repeats in a loop or reverses direction each time.
  • setInterpolator(TimeInterpolator): This object controls the timing behavior of the animation. By default, animations accelerate into and decelerate out of the motion, but you can change that behavior by setting a different interpolator. This function acts just like the one of the same name in the previous Animation class; it's just that the type of the parameter (TimeInterpolator) is different from that of the previous version (Interpolator). But the TimeInterpolator interface is just a super-interface of the existing Interpolator interface in the android.view.animation package, so you can use any of the existing Interpolator implementations, like Bounce, as arguments to this function on ValueAnimator.

ObjectAnimator

ObjectAnimator is probably the main class that you will use in the new animation system. You use it to construct animations with the timing and values that ValueAnimator takes, and also give it a target object and property name to animate. It then quietly animates the value and sets those animated values on the specified object/property. For example, to fade out some object myObject, we could animate the alpha property like this:

    ObjectAnimator.ofFloat(myObject, "alpha", 0f).start();

Note, in this example, a special feature that you can use to make your animations more succinct; you can tell it the value to animate to, and it will use the current value of the property as the starting value. In this case, the animation will start from whatever value alpha has now and will end up at 0.

You could create the same thing in an XML resource as follows:

    <objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:valueTo="0"
android:propertyName="alpha"/>

Note, in the XML version, that you cannot set the target object; this must be done in code after the resource is loaded:

    ObjectAnimator anim = AnimatorInflator.loadAnimator(context, resID);
anim.setTarget(myObject);
anim.start();

There is a hidden assumption here about properties and getter/setter functions that you have to understand before using ObjectAnimator: you must have a public "set" function on your object that corresponds to the property name and takes the appropriate type. Also, if you use only one value, as in the example above, your are asking the animation system to derive the starting value from the object, so you must also have a public "get" function which returns the appropriate type. For example, the class of myObject in the code above must have these two public functions in order for the animation to succeed:

    public void setAlpha(float value);
public float getAlpha();

So by passing in a target object of some type and the name of some property foo supposedly on that object, you are implicitly declaring a contract that that object has at least a setFoo() function and possibly also a getFoo() function, both of which handle the type used in the animation declaration. If all of this is true, then the animation will be able to find those setter/getter functions on the object and set values during the animation. If the functions do not exist, then the animation will fail at runtime, since it will be unable to locate the functions it needs. (Note to users of ProGuard, or other code-stripping utilities: If your setter/getter functions are not used anywhere else in the code, make sure you tell the utility to leave the functions there, because otherwise they may get stripped out. The binding during animation creation is very loose and these utilities have no way of knowing that these functions will be required at runtime.)

View properties

The observant reader, or at least the ones that have not yet browsed on to some other article, may have pinpointed a flaw in the system thus far. If the new animation framework revolves around animating properties, and if animations will be used to animate, to a large extent, View objects, then how can they be used against the View class, which exposes none of its properties through set/get functions?

Excellent question: you get to advance to the bonus round and keep reading.

The way it works is that we added new properties to the View class in Honeycomb. The old animation system transformed and faded View objects by just changing the way that they were drawn. This was actually functionality handled in the container of each View, because the View itself had no transform properties to manipulate. But now it does: we've added several properties to View to make it possible to animate Views directly, allowing you to not only transform the way a View looks, but to transform its actual location and orientation. Here are the new properties in View that you can set, get and animate directly:

  • translationX and translationY: These properties control where the View is located as a delta from its left and top coordinates which are set by its layout container. You can run a move animation on a button by animating these, like this: ObjectAnimator.ofFloat(view, "translationX", 0f, 100f);.
  • rotation, rotationX, and rotationY: These properties control the rotation in 2D (rotation) and 3D around the pivot point.
  • scaleX and scaleY: These properties control the 2D scaling of a View around its pivot point.
  • pivotX and pivotY: These properties control the location of the pivot point, around which the rotation and scaling transforms occur. By default, the pivot point is centered at the center of the object.
  • x and y: These are simple utility properties to describe the final location of the View in its container, as a sum of the left/top and translationX/translationY values.
  • alpha: This is my personal favorite property. No longer is it necessary to fade out an object by changing a value on its transform (a process which just didn't seem right). Instead, there is an actual alpha value on the View itself. This value is 1 (opaque) by default, with a value of 0 representing full transparency (i.e., it won't be visible). To fade a View out, you can do this: ObjectAnimator.ofFloat(view, "alpha", 0f);

Note that all of the "properties" described above are actually available in the form of set/get functions (e.g., setRotation() and getRotation() for the rotation property). This makes them both possible to access from the animation system and (probably more importantly) likely to do the right thing when changed. That is, you don't want to scale an object and have it just sit there because the system didn't know that it needed to redraw the object in its new orientation; each of the setter functions takes care to run the appropriate invalidation step to make the rendering work correctly.

AnimatorSet

This class, like the previous AnimationSet, exists to make it easier to choreograph multiple animations. Suppose you want several animations running in tandem, like you want to fade out several views, then slide in other ones while fading them in. You could do all of this with separate animations and either manually starting the animations at the right times or with startDelays set on the various delayed animations. Or you could use AnimatorSet to do all of that for you. AnimatorSet allows you to animations that play together, playTogether(Animator...), animations that play one after the other, playSequentially(Animator...), or you can organically build up a set of animations that play together, sequentially, or with specified delays by calling the functions in the AnimatorSet.Builder class, with(), before(), and after(). For example, to fade out v1 and then slide in v2 while fading it, you could do something like this:

    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(v1, "alpha", 0f);
ObjectAnimator mover = ObjectAnimator.ofFloat(v2, "translationX", -500f, 0f);
ObjectAnimator fadeIn = ObjectAnimator.ofFloat(v2, "alpha", 0f, 1f);
AnimatorSet animSet = new AnimatorSet().play(mover).with(fadeIn).after(fadeOut);;
animSet.start();

Like ValueAnimator and ObjectAnimator, you can create AnimatorSet objects in XML resources as well.

TypeEvaluator

I wanted to talk about just one more thing, and then I'll leave you alone to explore the code and play with the API demos. The last class I wanted to mention is TypeEvaluator. You may not use this class directly for most of your animations, but you should that it's there in case you need it. As I said earlier, the system knows how to animate float and int values, but otherwise it needs some help knowing how to interpolate between the values you give it. For example, if you want to animate between the Point values in one of the examples above, how is the system supposed to know how to interpolate the values between the start and end points? Here's the answer: you tell it how to interpolate, using TypeEvaluator.

TypeEvaluator is a simple interface that you implement that the system calls on each frame to help it calculate an animated value. It takes a floating point value which represents the current elapsed fraction of the animation and the start and end values that you supplied when you created the animation and it returns the interpolated value between those two values at that fraction. For example, here's the built-in FloatEvaluator class used to calculate animated floating point values:

    public class FloatEvaluator implements TypeEvaluator {
public Object evaluate(float fraction, Object startValue, Object endValue) {
float startFloat = ((Number) startValue).floatValue();
return startFloat + fraction * (((Number) endValue).floatValue() - startFloat);
}
}

But how does it work with a more complex type? For an example of that, here is an implementation of an evaluator for the Point class, from our earlier example:

    public class PointEvaluator implements TypeEvaluator {
public Object evaluate(float fraction, Object startValue, Object endValue) {
Point startPoint = (Point) startValue;
Point endPoint = (Point) endValue;
return new Point(startPoint.x + fraction * (endPoint.x - startPoint.x),
startPoint.y + fraction * (endPoint.y - startPoint.y));
}
}

Basically, this evaluator (and probably any evaluator you would write) is just doing a simple linear interpolation between two values. In this case, each 'value' consists of two sub-values, so it is linearly interpolating between each of those.

You tell the animation system to use your evaluator by either calling the setEvaluator() method on ValueAnimator or by supplying it as an argument in the Object version of the factory method. To continue our earlier example animating Point values, you could use our new PointEvaluator class above to complete that code:

    Point p0 = new Point(0, 0);
Point p1 = new Point(100, 200);
ValueAnimator anim = ValueAnimator.ofObject(new PointEvaluator(), p0, p1);

One of the ways that you might use this interface is through the ArgbEvaluator implementation, which is included in the Android SDK. If you animate a color property, you will probably either use this evaluator automatically (which is the case if you create an animator in an XML resource and supply colors as values) or you can set it manually on the animator as described in the previous section.

But Wait, There's More!

There's so much more to the new animation system that I haven't gotten to. There's the repetition functionality, the listeners for animation lifecycle events, the ability to supply multiple values to the factory methods to get animations between more than just two endpoints, the ability to use the Keyframe class to specify a more complex time/value sequence, the use of PropertyValuesHolder to specify multiple properties to animate in parallel, the LayoutTransition class for automating simple layout animations, and so many other things. But I really have to stop writing soon and get back to working on the code. I'll try to post more articles in the future on some of these items, but also keep an eye on my blog at graphics-geek.blogspot.com for upcoming articles, tutorials, and videos on this and related topics. Until then, check out the API demos, read the overview of Property Animation posted with the 3.0 SDK, dive into the code, and just play with it.

READ MORE - Animation in Honeycomb

Detect phone flipping

By checking Android's build-in accelerometer sensor status, we can detect the phone flipping (face-up/face-down).

Detect phone flipping

package com.exercise.AndroidDetectFlipping;

import java.util.List;

import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;

public class AndroidDetectFlipping extends Activity {

SensorManager sensorManager;
Sensor accelerometerSensor;
boolean accelerometerPresent;

TextView face;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

face = (TextView)findViewById(R.id.face);

sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
if(sensorList.size() > 0){
accelerometerPresent = true;
accelerometerSensor = sensorList.get(0);
}
else{
accelerometerPresent = false;
face.setText("No accelerometer present!");
}
}

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
if(accelerometerPresent){
sensorManager.registerListener(accelerometerListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
}

@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
if(accelerometerPresent){
sensorManager.unregisterListener(accelerometerListener);
}
}

private SensorEventListener accelerometerListener = new SensorEventListener(){

@Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub

}

@Override
public void onSensorChanged(SensorEvent arg0) {
// TODO Auto-generated method stub
float z_value = arg0.values[2];
if (z_value >= 0){
face.setText("Face UP");
}
else{
face.setText("Face DOWN");
}
}};

}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:id="@+id/face"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>


Download the files.

Related articles:
- Get the list of available sensors, SensorManager.getSensorList()
- Detect Android Accelerometer sensor changed
- Detect Shaking
READ MORE - Detect phone flipping

Data visualization of global Android device activations

Global Android Activations, Oct '08 - Jan '11


READ MORE - Data visualization of global Android device activations

Wednesday, February 23, 2011

Best Practices for Honeycomb and Tablets

The first tablets running Android 3.0 (“Honeycomb”) will be hitting the streets on Thursday Feb. 24th, and we’ve just posted the full SDK release. We encourage you to test your applications on the new platform, using a tablet-size AVD.

Developers who’ve followed the Android Framework’s guidelines and best practices will find their apps work well on Android 3.0. This purpose of this post is to provide reminders of and links to those best practices.

Moving Toward Honeycomb

There’s a comprehensive discussion of how to work with the new release in Optimizing Apps for Android 3.0. The discussion includes the use of the emulator; most developers, who don’t have an Android tablet yet, should use it to test and update their apps for Honeycomb.

While your existing apps should work well, developers also have the option to improve their apps’ look and feel on Android 3.0 by using Honeycomb features; for example, see The Android 3.0 Fragments API. We’ll have more on that in this space, but in the meantime we recommend reading Strategies for Honeycomb and Backwards Compatibility for advice on adding Honeycomb polish to existing apps.

Specifying Features

There have been reports of apps not showing up in Android Market on tablets. Usually, this is because your application manifest has something like this:

<uses-feature android:name="android.hardware.telephony" />

Many of the tablet devices aren’t phones, and thus Android Market assumes the app is not compatible. See the documentation of <uses-feature>. However, such an app’s use of the telephony APIs might well be optional, in which case it should be available on tablets. There’s a discussion of how to accomplish this in Future-Proofing Your App and The Five Steps to Future Hardware Happiness.

Rotation

The new environment is different from what we’re used to in two respects. First, you can hold the devices with any of the four sides up and Honeycomb manages the rotation properly. In previous versions, often only two of the four orientations were supported, and there are apps out there that relied on this in ways that will break them on Honeycomb. If you want to stay out of rotation trouble, One Screen Turn Deserves Another covers the issues.

The second big difference doesn’t have anything to do with software; it’s that a lot of people are going to hold these things horizontal (in “landscape mode”) nearly all the time. We’ve seen a few apps that have a buggy assumption that they’re starting out in portrait mode, and others that lock certain screens into portrait or landscape but really shouldn’t.

A Note for Game Developers

A tablet can probably provide a better game experience for your users than any handset can. Bigger is better. It’s going to cost you a little more work than developers of business apps, because quite likely you’ll want to rework your graphical assets for the big screen.

There’s another issue that’s important to game developers: Texture Formats. Read about this in Game Development for Android: A Quick Primer, in the section labeled “Step Three: Carefully Design the Best Game Ever”.

We've also added a convenient way to filter applications in Android Market based on the texture formats they support; see the documentation of <supports-gl-texture> for more details.

Happy Coding

Once you’ve held one of the new tablets in your hands, you’ll want to have your app not just running on it (which it probably already does), but expanding minds on the expanded screen. Have fun!

READ MORE - Best Practices for Honeycomb and Tablets

Wallpaper Emelexista

http://1.bp.blogspot.com/_azXJFXYprX4/TOC_J8gAgiI/AAAAAAAAAHE/ysqn2r9pxBM/s1600/IMG_7722.JPG
Etiqueta Azul: Pilar Vera - Modelo para Emelexista.com




http://4.bp.blogspot.com/_azXJFXYprX4/TOC_ZWuAH_I/AAAAAAAAAHY/KY92KoWOXn0/s1600/IMG_7819.jpg
Etiqueta Azul: Pilar Vera - Modelo para Emelexista.com


http://4.bp.blogspot.com/_azXJFXYprX4/TOC_jpTF4-I/AAAAAAAAAHk/28zAgLDXxok/s1600/IMG_7912.jpg
Etiqueta Azul: Pilar Vera - Modelo para Emelexista.com


unfuckingbeatable.xvideosmix.com


http://2.bp.blogspot.com/-O4l9yo5QVvs/TXBDVA6XSpI/AAAAAAAAAAc/9CuYXIXOoV0/s1600/barcelona%2Bcristiano%2Bronaldo.jpg
... Emelexista Que SE Creen Los Unicos Que Saben hacer Buenos Wallpapers


http://1.bp.blogspot.com/_azXJFXYprX4/TOC_crsNVMI/AAAAAAAAAHc/kHQvx0_NCAw/s1600/IMG_7823.jpg
Etiqueta Azul: Pilar Vera - Modelo para Emelexista.com


http://4.bp.blogspot.com/_azXJFXYprX4/TOC_QdihP8I/AAAAAAAAAHM/HaOCa208UVw/s1600/IMG_7736.jpg
Etiqueta Azul: Pilar Vera - Modelo para Emelexista.com


http://4.bp.blogspot.com/_azXJFXYprX4/TOC_NVwrD4I/AAAAAAAAAHI/E_wQ4dajLzY/s1600/IMG_7728.jpg
Etiqueta Azul: Pilar Vera - Modelo para Emelexista.com


http://4.bp.blogspot.com/_azXJFXYprX4/TOC_fqXcs7I/AAAAAAAAAHg/TTI3HL7AfsM/s1600/IMG_7826.jpg
Etiqueta Azul: Pilar Vera - Modelo para Emelexista.com


http://4.bp.blogspot.com/_azXJFXYprX4/TOC_m8uhEVI/AAAAAAAAAHo/X91uhmhhJJM/s1600/IMG_7918.jpg
Etiqueta Azul: Pilar Vera - Modelo para Emelexista.com


http://4.bp.blogspot.com/_azXJFXYprX4/TNS5fL45J1I/AAAAAAAAACw/xy3UlT-oxc0/s1600/EMELEC+musical.jpg
Etiqueta Azul: Wallpaper de Emelec


http://2.bp.blogspot.com/-hWAjuM72U3s/TXBC4KKvUXI/AAAAAAAAAAU/5z5ghYNwWQQ/s1600/barcelona%2Bgod%2Bof%2Bwar.jpg
Este es Uno de Todos LOs wallpaper que pienso subir a este blog Espero ...


http://3.bp.blogspot.com/-q763IAa51H0/UJch6HBKSnI/AAAAAAAABso/oHZOoH48dnI/s1600/Emelec_Escudo_3D_by_dajs3010.jpg
Imagenes De Emelec


http://3.bp.blogspot.com/-OvpPHF3gATM/TXBD1ZPzhJI/AAAAAAAAAAk/fOKCGF9iZRM/s1600/barcelona%2B1.jpg
este es otro recuerde que este blog es dedicado a el unico iolo del ...


http://2.bp.blogspot.com/-lQHnT5R_mts/TXBEVqGlrhI/AAAAAAAAAAs/SZwyjGxHzt4/s1600/barcelona%2B8.jpg
Publicado por Javier R. en 17:46 No hay comentarios:


http://4.bp.blogspot.com/-BY24qVWwJHE/TdFv9IUXS2I/AAAAAAAACp8/ppc9SK9biIE/s1600/IMG_1258.JPG
Fotos De Daysi Araujo 24 | Pelauts.Com


READ MORE - Wallpaper Emelexista

Tuesday, February 22, 2011

Full SDK for Android 3.0 is now available


The full SDK for Android 3.0 is now available to developers. The APIs are final, and you can now develop apps targeting this new platform and publish them to Android Market. The new API level is 11.

For an overview of the new user and developer features, see the Android 3.0 Platform Highlights.

Together with the new platform, the SDK Tools (r10) and ADT Plugin for Eclipse (10.0.0) have been updated also.

To get started developing or testing applications on Android 3.0, visit the Android Developers site for information about the Android 3.0 platform, the SDK Tools, and the ADT Plugin.

Source:
http://android-developers.blogspot.com/2011/02/final-android-30-platform-and-updated.html

READ MORE - Full SDK for Android 3.0 is now available

Final Android 3.0 Platform and Updated SDK Tools


We are pleased to announce that the full SDK for Android 3.0 is now available to developers. The APIs are final, and you can now develop apps targeting this new platform and publish them to Android Market. The new API level is 11.

For an overview of the new user and developer features, see the Android 3.0 Platform Highlights.

Together with the new platform, we are releasing updates to our SDK Tools (r10) and ADT Plugin for Eclipse (10.0.0). Key features include:

  • UI Builder improvements in the ADT Plugin:
    • New Palette with categories and rendering previews. (details)
    • More accurate rendering of layouts to more faithfully reflect how the layout will look on devices, including rendering status and title bars to more accurately reflect screen space actually available to applications.
    • Selection-sensitive action bars to manipulate View properties.
    • Zoom improvements (fit to view, persistent scale, keyboard access) (details).
    • Improved support for <merge> layouts, as well as layouts with gesture overlays.
  • Traceview integration for easier profiling from ADT. (details)
  • Tools for using the Renderscript graphics engine: the SDK tools now compiles .rs files into Java Programming Language files and native bytecode.

To get started developing or testing applications on Android 3.0, visit the Android Developers site for information about the Android 3.0 platform, the SDK Tools, and the ADT Plugin.

READ MORE - Final Android 3.0 Platform and Updated SDK Tools

Monday, February 21, 2011

Detect Shaking

By comparing previous and current reading of build-in accelerometer sensor, shaking of android device can be detected.

Detect Shaking

In this exercise, three SeekBar is used to adjust the sensitive of x, y, z. The changing rate are compare with the sensitive to detect shaking.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<SeekBar
android:id="@+id/xsensitive"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100"
/>
<TextView
android:id="@+id/x"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/xrate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/xstate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<SeekBar
android:id="@+id/ysensitive"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100"
/>
<TextView
android:id="@+id/y"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/yrate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/ystate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<SeekBar
android:id="@+id/zsensitive"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100"
/>
<TextView
android:id="@+id/z"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/zrate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/zstate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>


package com.exercise.AndroidDetectShaking;

import java.util.List;

import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.SeekBar;
import android.widget.TextView;

public class AndroidDetectShaking extends Activity {

TextView text_x, text_xrate, text_xstate;
TextView text_y, text_yrate, text_ystate;
TextView text_z, text_zrate, text_zstate;
SeekBar seekbar_x, seekbar_y, seekbar_z;

SensorManager sensorManager;
Sensor accelerometerSensor;
boolean accelerometerPresent;

float SensitiveX, SensitiveY, SensitiveZ;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

seekbar_x = (SeekBar)findViewById(R.id.xsensitive);
text_x = (TextView)findViewById(R.id.x);
text_xrate = (TextView)findViewById(R.id.xrate);
text_xstate = (TextView)findViewById(R.id.xstate);
seekbar_y = (SeekBar)findViewById(R.id.ysensitive);
text_y = (TextView)findViewById(R.id.y);
text_yrate = (TextView)findViewById(R.id.yrate);
text_ystate = (TextView)findViewById(R.id.ystate);
seekbar_z = (SeekBar)findViewById(R.id.zsensitive);
text_z = (TextView)findViewById(R.id.z);
text_zrate = (TextView)findViewById(R.id.zrate);
text_zstate = (TextView)findViewById(R.id.zstate);

seekbar_x.setOnSeekBarChangeListener(seekbar_sensitiveOnSeekBarChangeListener);
seekbar_y.setOnSeekBarChangeListener(seekbar_sensitiveOnSeekBarChangeListener);
seekbar_z.setOnSeekBarChangeListener(seekbar_sensitiveOnSeekBarChangeListener);

sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
if(sensorList.size() > 0){
accelerometerPresent = true;
accelerometerSensor = sensorList.get(0);
}
else{
accelerometerPresent = false;
}
}

SeekBar.OnSeekBarChangeListener seekbar_sensitiveOnSeekBarChangeListener
= new SeekBar.OnSeekBarChangeListener(){

@Override
public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2) {
// TODO Auto-generated method stub
if (arg0 == seekbar_x){
SensitiveX = (float)arg1;
}else if (arg0 == seekbar_y){
SensitiveY = (float)arg1;
}else if (arg0 == seekbar_z){
SensitiveZ = (float)arg1;
}
}

@Override
public void onStartTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}

@Override
public void onStopTrackingTouch(SeekBar arg0) {
// TODO Auto-generated method stub
}};

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
if(accelerometerPresent){
sensorManager.registerListener(accelerometerListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
}

@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
if(accelerometerPresent){
sensorManager.unregisterListener(accelerometerListener);
}
}

private SensorEventListener accelerometerListener = new SensorEventListener(){

float lastx, lasty, lastz;
long lasttime;
boolean firsttime = true;

@Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub
}

@Override
public void onSensorChanged(SensorEvent arg0) {
// TODO Auto-generated method stub
float x_value = arg0.values[0];
float y_value = arg0.values[1];
float z_value = arg0.values[2];
text_x.setText(String.valueOf(x_value));
text_y.setText(String.valueOf(y_value));
text_z.setText(String.valueOf(z_value));

long currenttime = System.currentTimeMillis();
if(!firsttime){
long deltatime = currenttime - lasttime;
float xrate = Math.abs(x_value - lastx) * 10000/deltatime;
float yrate = Math.abs(y_value - lasty) * 10000/deltatime;
float zrate = Math.abs(z_value - lastz) * 10000/deltatime;
text_xrate.setText(String.valueOf(xrate));
text_yrate.setText(String.valueOf(yrate));
text_zrate.setText(String.valueOf(zrate));

if (xrate>SensitiveX){
text_xstate.setText("Shaking:)");
}else{
text_xstate.setText("");
}

if (yrate>SensitiveY){
text_ystate.setText("Shaking:)");
}else{
text_ystate.setText("");
}

if (zrate>SensitiveZ){
text_zstate.setText("Shaking:)");
}else{
text_zstate.setText("");
}
}
lasttime = currenttime;
lastx = x_value;
lasty = y_value;
lastz = z_value;
firsttime = false;
}
};
}


Download the files.

READ MORE - Detect Shaking

Sunday, February 20, 2011

Detect Android Accelerometer sensor changed

Detect Android Accelerometer sensor changed

package com.exercise.AndroidAccelerometer;

import java.util.List;

import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;

public class AndroidAccelerometer extends Activity {

SensorManager sensorManager;
boolean accelerometerPresent;
Sensor accelerometerSensor;

TextView x, y, z;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
x = (TextView)findViewById(R.id.x);
y = (TextView)findViewById(R.id.y);
z = (TextView)findViewById(R.id.z);

sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
List<Sensor> sensorList = sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
if(sensorList.size() > 0){
accelerometerPresent = true;
accelerometerSensor = sensorList.get(0);
}
else{
accelerometerPresent = false;
}
}

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
if(accelerometerPresent){
sensorManager.registerListener(accelerometerListener, accelerometerSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
}

@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
if(accelerometerPresent){
sensorManager.unregisterListener(accelerometerListener);
}
}

private SensorEventListener accelerometerListener = new SensorEventListener(){

@Override
public void onAccuracyChanged(Sensor arg0, int arg1) {
// TODO Auto-generated method stub

}

@Override
public void onSensorChanged(SensorEvent arg0) {
// TODO Auto-generated method stub
float x_value = arg0.values[0];
float y_value = arg0.values[1];
float z_value = arg0.values[2];
x.setText(String.valueOf(x_value));
y.setText(String.valueOf(y_value));
z.setText(String.valueOf(z_value));
}};
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:id="@+id/x"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/y"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/z"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>


Download the files.

next:
- Detect Shaking
- Detect phone flipping

READ MORE - Detect Android Accelerometer sensor changed

Friday, February 18, 2011

Get the list of available sensors, SensorManager.getSensorList()

The class android.hardware.SensorManager provide a method getSensorList(). Use this method to get the list of available sensors of a certain type, or use Sensor.TYPE_ALL to get all the sensors.

Get the list of available sensors, SensorManager.getSensorList()

package com.exercise.AndroidSensorList;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class AndroidSensorList extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SensorManager sensorManager
= (SensorManager)getSystemService(Context.SENSOR_SERVICE);
List<Sensor> listSensor
= sensorManager.getSensorList(Sensor.TYPE_ALL);

List<String> listSensorType = new ArrayList<String>();
for(int i=0; i<listSensor.size(); i++){
listSensorType.add(listSensor.get(i).getName());
}

setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,
listSensorType));
getListView().setTextFilterEnabled(true);
}
}


Download the files.

Related Article:
- Detect rotation around X, Y & Z axis, using SensorManager and SensorEventListener
- Detect Android Accelerometer sensor changed

READ MORE - Get the list of available sensors, SensorManager.getSensorList()

Thursday, February 17, 2011

Display Gallery selected image using BitmapFactory

In last exercise "Select Image using Android build-in Gallery", we ask Android build-in Gallery app help to select image, with uri returned. In this exercise, BitmapFactory is used to load the image.

Display Gallery selected image using BitmapFactory

Modify main.xml to add a ImageView to display the returned image
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:id="@+id/loadimage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Load Image"
/>
<TextView
android:id="@+id/targeturi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ImageView
android:id="@+id/targetimage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>


Modify the code to load image using BitmapFactory.
package com.exercise.AndroidSelectImage;

import java.io.FileNotFoundException;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class AndroidSelectImage extends Activity {

TextView textTargetUri;
ImageView targetImage;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonLoadImage = (Button)findViewById(R.id.loadimage);
textTargetUri = (TextView)findViewById(R.id.targeturi);
targetImage = (ImageView)findViewById(R.id.targetimage);

buttonLoadImage.setOnClickListener(new Button.OnClickListener(){

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 0);
}});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);

if (resultCode == RESULT_OK){
Uri targetUri = data.getData();
textTargetUri.setText(targetUri.toString());
Bitmap bitmap;
try {
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(targetUri));
targetImage.setImageBitmap(bitmap);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}


Remark@2012-07-14: Recently found that it cannot display large image, such as original photos from camera ~ but I don't know why no error reported!!! Refer to the update post: Scale bitmap Efficiently.

Related:
- Convert URI to real path format
- Read EXIF of JPG file

READ MORE - Display Gallery selected image using BitmapFactory

Recipe Search Engine | World’s Largest Recipe Search Engine

Foodily.com - The Foodily Recipe Network lets chefs at home browse through the world’s largest recipe search engine for that perfect home-cooked meal.


The monstrous database pulls up recipes from all sorts of sites, from the Food Network to small foodie blogs. Foodily Recipe Network also lets users see what dishes friends like, making for a truly social experience. Cooks can even create Facebook events around recipes and share their favorite meals.

READ MORE - Recipe Search Engine | World’s Largest Recipe Search Engine

Wednesday, February 16, 2011

Select Image using Android build-in Gallery

If you have to select image from SD in your app, and don't want to implement a file browser by yourself; you can call the Android build-in Gallery to do so, using Intent.

Select Image using Android build-in Gallery

Here is a example:
package com.exercise.AndroidSelectImage;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class AndroidSelectImage extends Activity {

TextView textTargetUri;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button buttonLoadImage = (Button)findViewById(R.id.loadimage);
textTargetUri = (TextView)findViewById(R.id.targeturi);

buttonLoadImage.setOnClickListener(new Button.OnClickListener(){

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent intent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 0);
}});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);

if (resultCode == RESULT_OK){
Uri targetUri = data.getData();
textTargetUri.setText(targetUri.toString());
}
}
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:id="@+id/loadimage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Load Image"
/>
<TextView
android:id="@+id/targeturi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>


download filesDownload the files.

next:
- Display Gallery selected image using BitmapFactory

related:
- Send email with Image by starting activity using Intent of ACTION_SEND
Convert Uri return from Gallery to file path
- Convert between Uri and file path, and load Bitmap from.
READ MORE - Select Image using Android build-in Gallery

Wallpaper Chord Overstreet

http://2.bp.blogspot.com/-UCCG_j1u25o/T6gB0xS6mJI/AAAAAAAABRY/ELgReIJm5-8/s1600/wpdtv_chord+overstreet_1920.jpg
wallpapersdetv.blogspot.com




http://2.bp.blogspot.com/-vub_d8zVDUo/Ta-NgtJCk6I/AAAAAAAAAW8/G897a9Gxp4g/s1600/chord-overstreet-da-man-09.jpg
there's gonna be times in your life when people say that you can't ...


http://2.bp.blogspot.com/-wk4oKUPR0xs/TcXBTLWnXtI/AAAAAAAAANg/BwGBhxHk1A0/s1600/ChordOverstreet_1290378775.jpg
Download free chord overstreet pictures gallery | Free picture gallery


happinesstoitsextent.amateuryes.com


http://4.bp.blogspot.com/-WEaZ5okpoyg/UKRllzhLTyI/AAAAAAAApiI/M1Abm24iMIM/s1600/chord-overstreet-shirtless-01.jpg
Posted on Nov 18, 2012in Muscle Men Pix | No Comments


http://1.bp.blogspot.com/-tVhCJa1to-w/Tl_tnE7wDYI/AAAAAAAAAL4/EZ8k94FFVMM/s1600/closeup.jpg
James Marsters Spangel Fans 1 Astronauts or Cavemen


http://3.bp.blogspot.com/-QgUAGuKPw8g/TYSArvaWKZI/AAAAAAAACN4/4eN-5TDhhF0/s1600/england-wallpaper10.jpg
Posted by Daniel at 3:08 AM No comments:


http://2.bp.blogspot.com/_2w6AeiLLsyY/TU4TGnbksgI/AAAAAAABX34/u3PMCwzK9l4/s1600/Edita%2BVilkeviciute%2Bby%2BKarl%2BLagerfeld%2BFor%2BVogue%2BGermany%2BOctober%2B2009%2B13.jpg
Glee Star Chord Overstreet Goes Back To School On Season Three Of The ...


http://4.bp.blogspot.com/-xWGfUHSLYzY/TYSAr1sKRqI/AAAAAAAACOA/O_YQ_tNCxYc/s1600/england-wallpaper9.jpg
Posted by Daniel at 3:08 AM No comments:


http://3.bp.blogspot.com/_BdEeVDHjxLM/TUnKCDsqIII/AAAAAAAAAEk/9kFulc7s5IQ/s1600/RPattz-wallpaper-robert-pattinson-16746742-1024-768.jpg
The Fame: Estrenos esperados para el 2011


http://3.bp.blogspot.com/-KCbdRhdLa14/T47Fk9iY4BI/AAAAAAAADTY/wXOKISk5iys/s1600/Hayden+Panettiere-wallpaper-3.jpg
Onfolip: Hayden Panettiere Hd Wallpapers 2012


http://3.bp.blogspot.com/-jPW9XV42EIs/T47Fo-L_m8I/AAAAAAAADTo/BS2MXWaXfqo/s1600/Hayden+Panettiere-wallpaper-5.jpg
Onfolip: Hayden Panettiere Hd Wallpapers 2012


http://3.bp.blogspot.com/-l9YwbqUodvE/TahxvAzoytI/AAAAAAAABM8/UltcIK90GSU/s1600/jensen-ackles-wallpapers%2B%252812%2529.jpg
Gatos do Mundo: Jensen Ackles


http://1.bp.blogspot.com/_ZMrg5IGL6LQ/TVKsrxevlUI/AAAAAAAAADc/EtFHYHKscWI/s1600/gLee-Season-2-Promo-Wallpaper-glee-15819121-1922-1243.jpg
Top Row: Kurt, Rachel, Mr.Shue, Tina, Artie, and Mercedes Bottom Row ...


http://3.bp.blogspot.com/-odEw909Pxiw/T5PllqaSeAI/AAAAAAAAaRU/w_lrPwxSiz4/s1600/bruno-mars-wallpaper-17.jpg
Inside Josh's Mind: 'Marry You'


http://1.bp.blogspot.com/-cIrG2vFYvBY/T5QImsVPB2I/AAAAAAAADY0/Ct0Xr_fT7pY/s1600/Jamie+Chung-wallpaper-1.jpg
Onfolip: Jamie Chung Hd Wallpapers 2012


http://3.bp.blogspot.com/-FwtJa9Fx_ZE/TzmldopsadI/AAAAAAAAFM0/v_sX-8yicoM/s1600/papel+de+parede-avril+lavigne-walpaper-avril+lavigne+foto.jpg
As Estranhas Verdades Relativas: Casa da Praia 2012: Postagens Mais ...


http://3.bp.blogspot.com/-NXGO1jh1Uq0/T_OjtspkvqI/AAAAAAAACuI/xu2Vk6EPReo/s1600/GleeCastToiletPaper.jpg
PopGoesTheArts: Attention Gleeks: EVERYONE Is Returning For Season 4!!


http://4.bp.blogspot.com/-DS9-wA0MUis/T5hSg2GeBiI/AAAAAAAADmM/TqCSFLDJb7s/s1600/Jessica+Alba-1.jpg
Onfolip: Jessica Alba Hd Wallpapers 2012


http://3.bp.blogspot.com/-L_AK9Ni_ok8/T5QI5RALQ0I/AAAAAAAADZM/ZfXjZ6rHDP4/s1600/Jamie+Chung-wallpaper-4.jpg
Onfolip: Jamie Chung Hd Wallpapers 2012


http://1.bp.blogspot.com/-n32-_U3V6y0/T4W9Ojjv71I/AAAAAAAAGis/5-dCUi-pbHA/s1600/_Charlize_+Theron_+Wallpaper--0009.jpg
Onfolip: Charlize Theron Hot HD Wallpapers


http://4.bp.blogspot.com/-CZFLO58yfuc/TnZu_YMj3uI/AAAAAAAAAYs/kuT8Nbdlqf4/s1600/glee_2009_645_wallpaper.jpg
Mundo Gleek!: Wallpapers!


http://3.bp.blogspot.com/-ZNDR86XCf-0/T4W9DAHLeGI/AAAAAAAAGh4/zOuEw15oYjg/s1600/_Charlize_+Theron_+Wallpaper--0003.jpg
Onfolip: Charlize Theron Hot HD Wallpapers


http://3.bp.blogspot.com/-knv1w-rY-dQ/TmC9LNKDbJI/AAAAAAAAACk/a_f7YIYLDv4/s1600/Fire-Horse-wallpaper_600.jpg
Please click on the logo to continue to the Interkom.ca website


http://1.bp.blogspot.com/-1MEyVTvTOLk/T3xerKcf5mI/AAAAAAAACpI/1uLveHaOqNI/s1600/Elle+Fanning-wallpaper-1.jpg
Onfolip: Elle Fanning Hd Wallpapers 2012


http://4.bp.blogspot.com/-zk6UBmFmaGg/Th-kqzOttTI/AAAAAAAABoI/VYzrPqysn_I/s1600/Emma+Watson+cute+picture.jpg
Information & Technology: Emma Watson Hot Pictures


http://4.bp.blogspot.com/-jMSgGm550ic/T5fmsLeL2EI/AAAAAAAADfc/Kzb_GJQjDS8/s1600/Jennifer+Aniston-wallpapers-3.jpg
Onfolip: Jennifer Aniston Hd Wallpapers 2012


http://3.bp.blogspot.com/-0Gc35lWU0u4/T5QJPLUbOzI/AAAAAAAADZU/c42AFEKc4Cs/s1600/Jamie+Chung-wallpaper-5.jpg
Onfolip: Jamie Chung Hd Wallpapers 2012


http://3.bp.blogspot.com/-2_zn8Z7WnFw/T-k3hMKbjqI/AAAAAAAAABs/iRmGAPnlTdI/s1600/Emma%20Roberts%20wild%20child.jpg
Images Of European Style Haircut Emma Roberts And Alex Pettyfer Kiss


http://3.bp.blogspot.com/-hrVY2H3eUvI/T5QI3VtUyqI/AAAAAAAADZE/T5z7hdwjc9g/s1600/Jamie+Chung-wallpaper-3.jpg
Onfolip: Jamie Chung Hd Wallpapers 2012


http://4.bp.blogspot.com/-Wf9fM1hClX0/T4W857hZRFI/AAAAAAAAGhY/DHXHPuF_D2s/s1600/_Charlize_+Theron_+Wallpaper--00010.jpg
Onfolip: Charlize Theron Hot HD Wallpapers


http://1.bp.blogspot.com/-v6jm5o8xAr4/ToS5rZ_MH8I/AAAAAAAAAP8/GYMuxzM9ul4/s1600/DSC00724.JPG
Arduino Temperature Sensor


http://3.bp.blogspot.com/-tUoShZ9D-XE/Tg6k4RcqysI/AAAAAAAAAhc/qo0EKf0o3-E/s1600/Glee_Wallpaper_1024x768_Keyart.jpg
Mike O'Malley - Burt Hummel


http://3.bp.blogspot.com/-Za05kFk9wkI/TVVBWKEgcZI/AAAAAAAACTc/1mfZszxoKeA/s1600/miley-cyrus-hd-wallpaper-11.jpg
Miley Cyrus Wallpapers, Miley Cyrus New Wallpapers, Miley Cyrus HD ...


http://1.bp.blogspot.com/-bKSX37FjUaw/T4W9MGuv43I/AAAAAAAAGic/KRgpylGVJHA/s1600/_Charlize_+Theron_+Wallpaper--0007.jpg
Onfolip: Charlize Theron Hot HD Wallpapers


http://2.bp.blogspot.com/-DesmvB4wbp4/T4W9FakqsaI/AAAAAAAAGiM/47JBaigkIws/s1600/_Charlize_+Theron_+Wallpaper--0005.jpg
Onfolip: Charlize Theron Hot HD Wallpapers


http://1.bp.blogspot.com/-5c6GWZ9Oh70/UBH53mbWrtI/AAAAAAAAL8I/ROFL4cwiyGQ/s1600/Taman%2BBotani%2BKepong%2B1.jpg
Xstream - Auto Cleaning and Lawn Care Services


http://4.bp.blogspot.com/-tcZallCOkUY/T4W9Ee6mtqI/AAAAAAAAGiA/n-WMYhetlcU/s1600/_Charlize_+Theron_+Wallpaper--0004.jpg
Onfolip: Charlize Theron Hot HD Wallpapers


http://4.bp.blogspot.com/-PkqgYQXJmHE/TnYw3MvaM2I/AAAAAAAAAYI/R6R7sM0LHIE/s1600/novoposterseason34.jpg
Mundo Gleek!: Novas Fotos, Postêrs, Wallpapers da NOVA TEMPORADA DE ...


http://1.bp.blogspot.com/-HIQhCukQfE4/Td7CT-8VZgI/AAAAAAAAPxI/IiVd9PecYGc/s1600/Jakki%252BDegg8.jpg
PHOTOS: Julianne Hough at the: britney spears circus single


http://4.bp.blogspot.com/_ATHZap7c1Sg/TTJjgQYKUrI/AAAAAAAAAO4/jqwi_nK6-II/s1600/Artie-glee-7960939-1024-768.jpg
Glee Malaysia: January 2011


http://25.media.tumblr.com/tumblr_lw9z20cqyz1qbyw97o1_1280.jpg
Klaine Glee Wallpaper


http://25.media.tumblr.com/169b862ee2494e61cafe5e72f142d330/tumblr_mkw4bqoXpC1r2eyrho1_1280.png
images of when you finally find an amazing fic of a rare otp wallpaper


http://24.media.tumblr.com/tumblr_m4fv9e0vIl1rqq68jo1_1280.jpg
images of 24 media tumblr com wallpaper


http://24.media.tumblr.com/tumblr_m64ilqGG6d1rql7y6o1_1280.jpg
images of 24 media tumblr com wallpaper


http://24.media.tumblr.com/tumblr_lu6q6fe3KX1qbyw97o1_1280.jpg
zac efron # wallpaper # male actor wallpaper


READ MORE - Wallpaper Chord Overstreet
Related Posts Plugin for WordPress, Blogger...