Thursday, August 30, 2012

The temperature sensors (Sensor.TYPE_TEMPERATURE/Sensor.TYPE_AMBIENT_TEMPERATURE) are used to determine temperature of the phone, for internal hardware. They are not available on all device. (It's not available on my HTC One X and HTC Flyer!)

Sensor.TYPE_TEMPERATURE is deprecated, use Sensor.TYPE_AMBIENT_TEMPERATURE instead.

Wednesday, August 29, 2012

A funny story is sweeping the internet. Samsung paid $1.05 billion to Apple by sending 30 trucks containing five-cent coins.According to PaperBlog, the trucks were sent to Apple's main office in California this morning. Initially, the security of the company prevented the intrusion. However, Apple CEO Tim Cook received a call from the chief executive of Samsung that they have sent the payment for the fine ruled by the jury in the recently concluded patent battle of the two tech giants.The funny thing is, the story originated from a meme of the popular website 9Gag.com. Thus, the news report is a hoax.

Saturday, August 25, 2012

READ_EXTERNAL_STORAGE
Provides protected read access to external storage. In Android 4.1 by default all applications still have read access. This will be changed in a future release to require that applications explicitly request read access using this permission. If your application already requests write access, it will automatically get read access as well. There is a new developer option to turn on read access restriction, for developers to test their applications against how Android will behave in the future.

READ_USER_DICTIONARY
Allows an application to read the user dictionary. This should only be required by an IME, or a dictionary editor like the Settings app.

READ_CALL_LOG
Allows an application to read the system's call log that contains information about incoming and outgoing calls.

Tuesday, August 21, 2012

Decompiling Android looks at the the reason why Android apps can be decompiled to recover their source code, what it means to Android developers and how you can protect your code from prying eyes. This is also a good way to see how good and bad Android apps are constructed and how to learn from them in building your own apps.

This is becoming an increasingly important topic as the Android marketplace grows and developers are unwittingly releasing the apps with lots of back doors allowing people to potentially obtain credit card information and database logins to back-end systems, as they don’t realize how easy it is to decompile their Android code.

In depth examination of the Java and Android class file structures

Tools and techniques for decompiling Android apps

Tools and techniques for protecting your Android apps

What you’ll learn

How to download an Android app and decompile it into its original Java source and HTML5 and CSS code

How to protect your Android apps so that others cannot decompile it

To identify potential security threats that currently exist and how to avoid them

What tools are available to decompile and protect Android apps

The structure of a Java Classfile and an Android classfile

How the standard JVM and the Dalvik JVM differ

How to create your own Android decompiler and obfuscator

Who this book is for

This book is for Android developers and their managers. It's also for hackers and hobbyist types who wish to see how Android apps are constructed as a means of learning how to build Android apps.

Fragment.setRetainInstance (boolean retain) control whether a fragment instance is retained across Activity re-creation (such as from a configuration change). This can only be used with fragments not in the back stack. If set, the fragment lifecycle will be slightly different when an activity is recreated:

onDestroy() will not be called (but onDetach() still will be, because the fragment is being detached from its current activity).

onCreate(Bundle) will not be called since the fragment is not being re-created.

onAttach(Activity) and onActivityCreated(Bundle) will still be called.

Example:

In the example, there are two Fragment, MyFragment and MyFragment2. Basically, both Fragments are same, except that MyFragment2 call setRetainInstance(true) in onCreate(). It can be noticed that onCreate() and onDestroy() of MyFragment2 will not be called when orientation change, and the field myState of MyFragment2 will not be cleared.

To maintain the old states, we can overriding the method onRetainNonConfigurationInstance() to return the old activity. Via the returned activity object, we can retrieve the fields of the old activity.

Please notice that the method onRetainNonConfigurationInstance() is deprecated, If you are targeting HONEYCOMB or later, consider instead using a Fragment with Fragment.setRetainInstance(boolean).

Modify the java code in the exercise "GridView loading photos from SD Card", override the method onRetainNonConfigurationInstance() to return the activity object, this. In orCreate() method, check if old activity exist by calling getLastNonConfigurationInstance(). If the returned object not null, means old activity exist.

Here is a example, there are two EditText in the layout. The first one is assigned with a ID, it will update the TextView once text changed. The second one have no ID assigned. You can notice that the text in the first EditText (with ID) will keep no change after orientation changed, and onTextChanged() method of the TextChangedListener will be called also, to update the TextView.

On the other hand, the second EditText (without ID assigned) will clear to empty when orientation changed.

Monday, August 13, 2012

Preview 1 is mostly a bugfix release. It contains a number of bug fixes in various areas that were new in ADT 20, such as the new template infrastructure. Whereas 20.0.1, 20.0.2 and the upcoming 20.0.3 contained a small number of absolutely critical fixes, ADT 21 contains a much larger number of general bug fixes and infrastructure improvements.

ShareActionProvider was introduced since API Level 14. This is a provider for a share action. It is responsible for creating views that enable data sharing and also to show a sub menu with sharing activities if the hosting item is placed on the overflow menu.

Modify /res/menu/activity_main.xml to define the android:actionProviderClass attribute for the corresponding in your menu resource file.

In order for ShareActionProvider to function, you must provide it a share intent. Find the corresponding MenuItem while inflating your menu resource in your Activity or Fragment. Next, call MenuItem.getActionProvider() to retreive an instance of ShareActionProvider. Use setShareIntent() to update the share intent associated with that action item. ~ refer to onCreateOptionsMenu(Menu menu) in the code.

When you need to update the content to be shared (ex. EditText changed, photo attached), call setShareIntent(shareIntent) again to update the intent. ~ refer setShareIntent(Intent shareIntent) in the code.

Wednesday, August 1, 2012

With Dalvik Debug Monitor Server (DDMS) in Android SDK Tools (or the new screen capture feature on Android 4), it's easy to capture your current screen. How to...if you want create device artwork like the one in right?

With Device Art Generator, you can create device artwork with your own screen easily. The device art generator allows you to quickly wrap your app screenshots in real device artwork. This provides better visual context for your app screenshots on your web site or in other promotional materials.

Simple steps to generate device artwork using Device Art Generator:

Drag a screenshot from your desktop onto a device shown in screen.

Customize the generated image and drag the generated image to your desktop to save.

The Google Play Developer Program Policy (“Content Policy”) updated. Improvements include the addition of clarifying language for existing policies, support for new Google Play features and content, as well as the introduction of a new section addressing ad behavior in apps.

Visit and familiarize yourself with the above policies. If you find any existing applications in your catalog to be in non-compliance, Google ask you to remedy and republish the application within 30 calendar days of this notification. After this time period, applications discovered to be in violation may be subject to removal from Google Play. Any newly published applications must adhere to the latest version of the Content Policy for Google Play.