android

Android Database Access Across Tabs

I have four tabs (reports, review reports, map and settings). I have an sqlite database populated with report information. I wish to have the database accessible throughout the application. The reports tab successfully adds data to the database however using the same methodology crashes the application. The Android debugger points to the...

Can I catch uninstall action in my Android app

public class Unistallreceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { // TODO Auto-generated method stub String action = intent.getAction(); if (action == null) Log.e("uninstall ", "Action==null!"); els...

How to update SimpleAdapter in Android

Is it possible to update a SimpleAdapter? I have a list of data and a footer that says "See Next Results" When that list item is clicked I capture the event and get new data. I then want to replace the data in the ListView with this new data but I can't figure out how to do it. Any Ideas? I don't want to use an ArrayAdapter, cause as...

Setting ListView scroll position nicely in Android

I am aware of setSelection(), setSelectionFromTop(), and setSelectionAfterHeaderView(), but none of them seems to do what I want. Given an item in the list, I want to scroll so that it is in view. If the item is above the visible window of the list, I want to scroll until the item is the first visible item in the list; if the item is b...

Absolute Centering in Android Layout

Hi guys, I've spent so much time trying to figure this out. I'm building a dialog layout and trying to get the Title centered relative to the dialog while having 2 buttons on either side of the title. The buttons are to be 'gravity-ed' towards far left and far right. The easy part is centering the dialog, OR doing the buttons far lef...

How do I pass a R.drawable as a parameter so I can get images parsed

I try to save a unique image to each object but I get this error, how should the constructor look for it to work that way? The constructor Beer(String, int, int) is undefined m_beer = new ArrayList<Beer>(); final Beer b1 = new Beer("Tuborg", 7, R.drawable.tuborg); final Beer b2 = new Beer("Carlsberg", 7, R.dr...

Callback before Force Close of Android Activity?

I'd like to have some emergency cleanup code execute just before my app crashes. I tried using onDestroy(),, onFinal() and finalize() to no avail. Is this possible in an Android Activity? ...

Do ListView's getFirstVisiblePosition and getLastVisiblePosition lie?

I've got my ListView on screen. It's scrolled to the top. I see 6 rows. And when I Log getFirstVisiblePosition() and getLastVisiblePosition(), it says 0 and 6. Is getLastVisiblePosition() actually returning the first non-visible position? In other words, should my test for whether a particular row is onscreen be not first <= row &&...

What's the learning curve for Android?

What has people's experience been in learning Android? I'd be interested in how long it takes to get to the point where you're writing your first app, and how the experience compares to learning some other programming API. I know several professional programmers who have tried to learn Android and failed. Is it inherently more difficu...

Android: UnknownHostException

I am using Android SDK 2.2, testing my application with the emulator. I want to send a HTTP Post. When I do I get a UnknownHostException. I have placed the required permissions <uses-permission android:name="android.permission.INTERNET" /> in the manifest.xml. Also I can open the browser on the emulator and navigate to the URL with no ...

Delete row in database table given one column value - which is a string

I have a table with column headings: | _id (long) | Name (String) | x (integer) | y (integer) | I want to delete the row in the table that has Name myName. // In onCreate dbHelper = new DBAdapter(this); dbHelper.open() // Function in DBAdapter class public boolean deleteTitleGivenName(String myName) { return dbHelper.delete(DATAB...

starting a new activity throws me into debug mode and stops the app.

I have a listview. Whenever I strike an item of listview the debugger gets opened instead of starting a new activity (i.e. what I want). here is the listview code.. setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, s)); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClick...

Android ListView with two columns that only takes up bottom part of the screen.

I'm trying to add a listview on the bottom of my opening activity that has two text items. Anyone know how to do this? I see stuff on how to do a listview with two columns, and how to do a listview at the bottom of an activity, but I can't find any that does both. ...

Deleting row from database using _id column in context menu from ListView

Hello, I have a listview which is populated by a SimpleCursorAdapter that is binding data to the view from a cursor from a sqlite database. I would like to have a context menu option to delete the a list item when it is long pressed, so I register the ListView for a context menu by calling registerForContextMenu(historyListView). I've be...

Android accessing buttons created dynamically

If I create buttons dynamically in a loop, for(i=0; i < size; i++) { Button button = new Button(this); myLayout.addView(button); } How can I reference each of these buttons at a later time? So, for eg, if I wanted to change the text on a few buttons, how would I do that? Thanks Chris ...

Android multiple gradient xml

is there a way to have 2 gradients in a drawable xml using either a <layer-list> or <shape> or some combination of them? ...

How to invoke recoding sound/voice functionality in android

Hi, Can you please tell me where I can find example in how to invoke andord recoding sound/voice functionality? Thank you. ...

Android Debugging Tips

Often my programs simply crash. I can't see anything in the LogCat or otherwise useful information elsewhere to find out what's gone wrong. The only thing I see is some kind of exception. This is unacceptable and makes Android programming nearly impossible. I'm sure there must be some additional help to debugging, but after weeks of ...

what the error message "AFCCreateReSampler: avAFCInfo->bUsed[0] in SampleRate[44100] outSampleRate[16000]..." mean?

Hello, On an Android 2.1 device (Samsung Galexy S), I am trying to record audio data using the following code. int frequency = 16000; int channelConfiguration = AudioFormat.CHANNEL_IN_MONO; int audioEncoding = AudioFormat.ENCODING_PCM_16BIT; int bufferSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, a...

Android GPS Only Communicates After Google Map Runs

I looked for the answer but didn't find one - my question(s) follow: I wrote code that works with the emulator (I send local coords vis DDMS). The code also works on the device BUT, only after running Google Map. I'm guessing there's something missing in either the manifest or in the code but I don't know what it is and I could use so...