Applying style to views dynamically in java code

In my answer to Applying style to views dynamically in java code on Jun 25 at 18:51, I thought setting a style to a view dynamically would be as simple as passing the style to the constructor of your view. A couple of minutes ago, I had a notification and a comment (Thank you for it) saying that this does not work. I had a freaking -1 ):

Application which always requires Login

In this tutorial is an attempt to disallow the user to resume an application without signing in again. Whatever happens that causes my app to go off-screen should force the user to sign in again. In this context, signing in is rather case-specific: Say, every time the app is hidden and then shown again, the app will go to one specific activity.

PART II: How to implement GCM PhP Push Server for android

In PART I: How to implement GCM PhP Push Server for android, I have concluded with a function to send a push notification to a single device.
This part only describes the function that may be used to send to multiple devices the same push message.

UI Trick: Sliding content

Here is a small trick that I use sometimes to show a related content in an activity. In the back of my mind, my intention might be to mimic the iphone's presentModalViewController. This would specifically be useful when you have a list of items which users might repeatedly click items to view an Expanded view of them. I prefer to use this instead of a new Activity.

How to send status Notification android

Here is a small function you can use to send a notification in android using the new Api which recommends using Notification.Builder. It still works on older 2.2+ devices.

The main components of the Notification are the tickertitlecontent, and intent:

How to create a Splash Activity - best practices

In this small tutorial, I will explain how to add 2 types of splash activities in Android:

  1. Splash that shows a simple layout
  2. Splash that plays a movie

While working on different projects, I discovered that splash activities are really simple to create. You just create some xml layout for your activity, create the activity, and set a timer after a couple of seconds with a Runnable that starts another activity.

PART I: How to implement GCM PhP Push Server for android

In my previous post, GCM replaces C2DM, I was just expressing my happiness of what I think is the best of the new Google Cloud Messaging.

Now this is a small guide for those who would like to add push notifications to their applications:
This part will explain how to prepare your server to send push messages. In another post, preparing the android app will be discussed.

GCM replaces C2DM

Finally! good news from the android team! The old c2dm is deprecated and the new GCM is here:
Same concept but much better features.

I need to say that the best news is that we can finally get push messages as fast as an iphone does. Put simply, we can now send to multiple devices the same push message in one request!!!!

How to play a video from resources

As am getting lots of good feedback on my answer on SO for the question How to play a video from the raw or assets folder, I thought of writing this small tutorial on playing a video in your activity.

String arrays and Object arrays in SharedPreferences

I see many questions on SO asking about the best mechanism to store some kind of preferences such as statistics, favorites, or shortcuts. Many of these questions are answered with "Use a database".

The biggest, yet clear, secret is that SharedPreferences are actually implemented using a

ListView with ability to hide rows

I do not know why! but someone on stackoverflow was asking about setting the height of a row of a ListView to zero.

Setting the height to zero will not work indeed! Many suggest to use View.Gone for the visibility of the row. However this is a ListView and therefore, setting a Visibility of Gone to one of the views will actually keep its space occupied while making its content vanish.

Anyway, here is an implementation of ArrayAdapter that has two public functions hide(int) and unHide(int) allowing the user to hide/unhide the row at the position.

Adding an Exit button to Android Application

So what is the right way of closing the application!

Usually it is "USER! press back ! press back! keep pressing back! we are close!! okay finally bye"

Here is a small idea i had on adding an Exit button to application.

In my personal opinion, even android users will find a Close button nice and friendly.

Passing primitive Data types between activities

After some time working on android projects, I discovered that it is actually very important to pass data between activities in most projects. It is rather simple when it comes to passing primitive datatypes.