android

activity.onPause not always getting called

For some reason the onpause method is not always getting called when my app is put into the background. Either that or the MyLocationOverlay is not properly disabling. My app uses google maps and the MyLocationOverlay. When starting the app, I call MyLocationOverlay.enableMyLocation() in the onResume method. In the onPause method I cal...

Button not working after TranslateAnimation ends.

Im tring to simulate a slideup animation.The idea is to slideup and slidedown the tablelayout with the id searchForm when pressing the button so that i can use the extra space for a list. I managed to slideup the searchForm and the button and the list seems to be visible but after this i cant click the button, here's the code responsible...

Android: How do you capture a screenshot of your own app programatically

I know you need root access if you want to capture a screenshot by using a background application. However is it possible to just grab the screen content of your current visible activity owned by your process? This does not seem like a security constraint since the user has already installed your app is currently using your app. If so ho...

Problem with "has leaked window" on dialog.

I am writing an android app to give the user the option to call a different alternative number based on the number he tried to call. To do that I have BroadCastReceiver that gets the number being called, checks if there are alternatives and then to show the dialog it starts a new activity to do that as it can not do on its own. Everythin...

facebook: Your link could not be shared

I'm adding the ability to share scores from my app using android's share intent: Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Score"); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I scored "+score+" on "+...

Child headers for ExpandableListView using CursorTreeAdapter

How do I create a header for every expanded ChildView without affecting my underlying data and onClick / onLongClick events on the ChildView. Below is the skeleton implementation of my ExpandableListView adapter: private class EAdapter extends CursorTreeAdapter { public EAdapter(Cursor cursor, Context context) { super(cursor, contex...

Using SharedPreferences and/or class variables in an Activity

Just a random question. I'm learning a bit of Android right now, and in most examples, it seems a lot of common items (such as buttons, editboxes etc) get requested within each function using (cast) findViewById(). Is it considered good or bad practice to store the result of that in an Activity's member values? Simple example: public c...

Android HTTP POST Content-Length Exception

I have a simple program that sends an HTTP POST. It works only if the line httpost.addheader("Content-Length","18") is not present. Otherwise it fails. In the code, it's the line with "--->" Commenting this line out makes the POST succeed. Android does not send the POST if that line is in the code and returns with a Protocol Exception ...

drawing part of a bitmap on an Android canvas

How can you blit a non-rectangular (e.g. oval) part of a bitmap into a canvas on Android? Consider how you'd blit a rectangular part of a bitmap: canvas.DrawBitmap(src,src_rect,dest_rect,paint). Sadly there is no corresponding methods for non-rectangular regions. Four approaches present themselves (maybe you know a fifth?): copy the...

Get right part of string in Android app

Ok, I am trying to get the right three characters of a string in an Android app I'm writing. Based on the research I've done in the SDK and online I should be able to use something like the following to do it. millisecondsD = millisecondsD.substring(millisecondsD.length() -3, millisecondsD.length()); However, I get a force close when...

Strange drawing artefact using custom drawable with MapView

I'm trying to add my own drawable and use it in a series of overlays on a MapView. The drawable is basically a rounded box with a black outline and a number in the middle. I have managed to achieve this using the code below, however there is what looks like a flag to the left of my box, which I certainly don't think I have drawn - so I...

How to create list with different elements and actions?

I want to create list with different types of items. They should call different intents or do other things (display a map etc.) . It should act like contact details. Numers of items and actions is predefined. How to achieve this effect elegantly? I don't need exact code but guidelines and information where to look. Any help will be ap...

Adding new feature in address book in android

Hi is it possible to add new feature in existing address book?? What i am trying to do is i want to add my application shortcut just like there is a shortcut for sms into every contact, whenever user opens any contact he can see my application option there, he taps to it and my application will launch with that contact information is it...

Android ListView with multiple select and custom adapter

Hello, I have a ListView with a custom adapter. The ListView allows multiple select, but somehow it's not recognising when an item is selected. I've already made the adapter items extend Checkable, but still the getCheckedItemPositions() returns an array of falses. I guess there's something fundamental I'm doing wrong, but I have been ...

Widget Implementation Advice Needed

Hi, I'm new to Android and I want to write a widget that contains (about)100 columns, each column contains various amount of child views (will be determined at run time via some service call). Users can scroll horizontally and vertically (similar behavior as GridView but with horizontal scrolling). The child views will be customized widg...

Best practice to pull content from the web?

I'm new to developing Android applications, and have only a little experience with Java in school. I was redirected to StackOverflow from the Google groups page when I was looking for the Android Beginners group. I have a question about what is best practice to pull content from a web source and parse it. Firstly, I would eventually lik...

Determining even/odd numbers (integers)?

I feel stupid asking such a simple question, but is there an easy way to determine whether an Integer is even or odd? ...

How develop Android applications?

I'm really new with this thing of "Android development" and I was really excited when I found Appcelerator Titanium, but now I got the big surprise, it doesn't work on my computer. What other alternatives are there for Android development specially if they include HTML, JavaScript and CSS for creating such applications? ...

Way to be notified when the software keyboard is showing/hiding?

Is there a way to be notified when the keyboard is about to show, or has shown? The following events would be great: keyboardWillShow keyboardDidShow keyboardWillHide keyboardDidHide ...

Android ActivityList - Loading data from network best practice

Hello, I have multiple ListActivity(s) with a custom ArrayAdapter. I have to load an XML file from the Web, and the user moves to a new activity by selecting a list item. What is best practice for: Displaying a loading indication to the user. Threading the networking stuff so that the user can cancel the loading of the data if need b...