Android: long click on a button -> perform actions

I want to use the same button to perform 2 different methods. One method when user single clicks it and a second method (different) when the user LONG clicks it. I use this for the single short click (which works great): Button downSelected = (Button) findViewById(; downSelected.setOnClickListener(new OnClickListener() { public void onClick(View v) { method(); […]

Android Checkable Menu Item

I have the following menu layout in my Android app: <?xml version=”1.0″ encoding=”utf-8″?> <menu xmlns:android=””> <item android:id=”@+id/item1″ android:titleCondensed=”Options” android:title=”Highlight Options” android:icon=”@android:drawable/ic_menu_preferences” /> <item android:id=”@+id/item2″ android:titleCondensed=”Persist” android:title=”Persist” android:icon=”@android:drawable/ic_menu_preferences” android:checkable=”true” /> </menu> My problem is that the second menu item doesn’t appear to be “checkable” when I run my app in the Android emulator. There should be […]

Android: How to create an “Ongoing” notification?

Hello, How do i create the permanent notification like the first one for Battery Indicator?

How to fully replace listView/GridView with RecyclerView?

I’ve noticed that the new RecyclerView class, even though it makes things a bit cleaner, is lacking a lot of functionality that I’m familiar with: dividers, but this can be solved by looking at this post or this one “footerDividersEnabled” “headerDividersEnabled” “listSelector” , but maybe I should simply set it per view ? “fastScrollEnabled” “smoothScrollbar” […]

converting a canvas into bitmap image in android

I am trying to develop an app on canvas,I am drawing a bitmap on the canvas.After drawing,i am trying to convert into bitmap image. can anyone give me a suggestion. thank you in advance.

Should I use getApplicationContext or Activity.this in a long running AsyncTask

I have a long running Async Task that sends some data to my server and then stops. The whole process may involve a few requests and response. I have to read data from database, send it and handle the response and update my database accordingly. I am using content providers to read and update data […]

Help with a custom View attributes inside a Android Library Project

I have a custom PieTimer View in an Android Library Project package; public class PieTimerView extends View { … I also have a XML attributes file which I use in my PieTimer TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PieTimerView); The XML styleable file looks like this <?xml version=”1.0″ encoding=”utf-8″?> <resources> <declare-styleable name=”PieTimerView”> <attr name=”max_size” format=”dimension” /> […]

Getting the current time zone in android application

This question already has an answer here: How to get TimeZone from android mobile? 6 answers

Exception when opening Parse push notification

I setup Parse push Android SDK 1.7.0 and can receive pushes without any problem. However, when opening the push notification my app crashes with the following exception: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat= flg=0x1000c000 (has extras) } I also tried subclassing ParsePushBroadcastReceiver with getActivity() always returning the main activity class, same […]

Is it possible to make a ListView populate from the bottom?

I have a simple application which basically consists of a line of buttons and a ListView of items to be selected and manipulated. There might be only one item in the list or a few. However, I would prefer if the list would populate from the bottom of the ListView, since the way most people […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.