android

What is the mechanism behind startActivityForResult() in Android ?

I have an activity. In this activity I want to start another activity using startActivityForResult(). I understand that my basic activity is started within a process with a main GUI thread. But as far as I understand, startActivityForResult() is asynchronious which means that my new activity will be executed in a different thread. I ca...

multiple drawables from one xml file

I want to use a number of ShapeDrawables in my application, which are all similar, but with different colours etc. Obviously I could just define them all in separate xml files, but is there a more efficient way to have one xml definition, instantiate various objects and change the colour either in code or xml? You could perhaps do this b...

Android database query

I have a database table with 3 columns: _id, name, groupName It looks similar to this: 1 Tom group1 2 Sam group1 3 Ted group2 4 Jerry group3 5 Me group3 I want to query the database table for groupName. I have tried this: public Cursor getAllGroups() { return db.query(DATABASE_TABLE_1, new Stri...

Keep getting NullPointerExceptions when attempting to call getWritableDatabase()

Hi all, I'm new to the Android framework and I can't get past first base with SQLite. I'm trying to build a very simple application that has a EditText search box, which when a key is pressed performs a Like %word% search on a SQLite database for for the text entered in the EditText box, and displays the results in a ListView. N.B. the...

eclipse intellisense with Android SDK

I am using the latest Android SDK (2.1-update1 - Level 7) but I am finding that the intellisense is rather poor in Eclipse. Is it just me or is anyone else experiencing intellisense issues with Android SDK? ...

Android Form EditText Show Keyboard onResume

When my Activity is loaded, I wish the txtEdit EditText widget to get focus and show the keyboard. I tried this in the onResume() but it does not automatically show. @Override protected void onResume() { InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showSoftInput(txtS...

How do I use androids LayoutInflater.Factory to create a custom view class instead of a built in class?

I am using a custom class based off RelativeLayout but it obviously doesn't render in the Eclipse layout editor. I have found this article regarding LayoutInflater.Factory and it sounds like what I need to be doing but I can find no guides to using LayoutInflater.Factory. http://www.macadamian.com/blog/post/android_-_custom_classes_fro...

Weird bug with setting LayoutParams margins

I'm having this weird issue with a custom TextView I'm working on. I'm trying to move the view by dragging it with a finger, so I get the touch position, do some math, and set the corresponding leftMargin and topMargin. It works, but I get some very weird behavior. The leftMargin part works perfectly, but the topMargin is very jumpy. It ...

does android.media.SoundPool cause memory leak?

hi, friends, i found these code may case memory leak on android 2.1 SoundPool soundPool = new SoundPool(10, 7, 0); ... ... soundPool = null; every time after the execution, the MAT pluging tells that two String objects of "android:unnamed_thread" are added to the heap of the process. is that an issue? ...

How do a share a large object within an activity in Android?

I have a Network Client class that is receiving a large binary block and parsing it into a usable Java object. The Network Client is on a separate thread from the app's View. What is the best way to make this object available to the View? I've come up with the following solutions, but I feel like none of them are the correct one: Creat...

How to track referral install from Android Market?

I have this in my manifest file: <receiver android:name="com.google.android.apps.analytics.AnalyticsReceiver" android:exported="true"> <intent-filter> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> but I don't see the install data in my GA. I am wondering if I missed out something. ...

How do I insert line breaks into a text file i'm creating on the SD Card?

My code is pretty standard.. sReport contains the text I would like output to the text file, and it contains several "\n" line breaks that render fine in a textview, but in the text file they're non-existent. There must be something easy i'm missing.. try { FileOutputStream fOut = new FileOutputStream(sDir + sFile); ...

Is there any way to look for an image using the path? MediaStore.Images.Thumbnails (Android)

Hi, I'm using MediaStore.Images.Thumbnails in order to show the images the user have. But i'm not able to get an image through its path. Is there any way to look for an image using the path? String [] proj={MediaStore.Images.Thumbnails._ID, MediaStore.Images.Thumbnails.IMAGE_ID, MediaStore.Images.Media.DATA}; String selection = Media...

Saving data at web server

Hi, I want to save the data on the web server. I have data in XML format and I know the URL String. Please tell me how can I send the request and handle the response. Thanks Deepak ...

observer pattern in Android

I have a problem. 1. I have two threads 'worker' and 'UI' thread. 2. worker keep on waiting for data from server, when gets it notifies to UI thread. 3. On update UI Toast a msg on screen. Step 3 is problem as it says android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch ...

Can I use any Android Phone for application development?

Hi! Can I use any Android Phone for app development? Here in the Philippines, there are many available mobile phones with Android installed. But I want to buy the cheapest phone available (which I think is Samsung i5500 Galaxy 5). Thanks in advance! ...

What is a Sticky Intent? [Android]

I came across this term in the android documentation with the accompanying definition These are broadcasts whose data is held by the system after being finished, so that clients can quickly retrieve that data without having to wait for the next broadcast. What does it mean? Can someone elaborate its use with a particular example? ...

x10 read drawable-mdip files instead of mdip

Hi everyone, I am developing an application for several android devices which include x10,x10 mini and nexus-one, so I have to re-szie all graphics for all 3 screen size(480,320,240), but when I deploy the application onto x10(480x854),it gets mdip files instead of hdip files, and all images become blur because using 320 pixel width ima...

how to limit seekbar

HI All , i want to giv max and minimum limit of seekbar to 50 and 20 respectively. seekbar has a direct option top provide max value,but how can i set its minimum value to 20 rather than 0?? regards ...

Changing ImageView on button click

Wondering if I'm going about this the right way or not. I have 3 buttons on my screen (Restart, Previous, Next). When the view loads it shows the first image which is fine. When I click the "Next" button I want it to load a second image and so on for up to 9 images. If I click the "Previous" button it should go back one image. Clicking "...