android

Android Emulator: select AVD (Android Virtual Device) to run by default

I have added a second Virtual Device to test a different screen resolution (QVGA), but now I wanna switch back to the first AVD (HVGA) again. How can I set the virtual device in Eclipse to be used by default or even specifically for my project? In the properties I can only set the API level. I also couldn't find any information in the c...

Specifying the relative dimension of views in a layout based on device screen width/height

I am writing an android application that has 3 views one below the other. Each view has to be of equal height, depending on the screen size. Each view occupies the full width of the screen. How do you specify in the layout xml that the view has to take up 1/3rd height of the device display height? What would be the appropriate layout to ...

Android:android.view.ViewRoot$CalledFromWrongThreadException - How to solve the problem?

Hi, An application I am currently developing is communicating with the server and the communication process runs in its own thread. There are asynchronous calls - for example login() and onLoginResponse(). login() is called in the main activity and the response is handled in main activity as well (onLoginResponse()). In onLoginResponse...

Indirectly extend Activity

For ease of use I want to extend an Android Activity with a certain class to give it extra functionality and then extend my main activity with that class e.g. class SuperActivity extends Activity { //Very nice extra functions } //Class defined in the manifest.xml class ApplicationActivity extends SuperActivity { //Start the app...

How to call built-in camera app from my own application in Android?

Being a newbie to Android I can't work out how to call the camera application (or you can say camera preview?) when I click a button in my custom application. ...

How to use default account parameters (login/pwd) in Android phone?

Howdy, I want to use default Android credentials for specific phone to pass authentication test in Google Apps, but documentation is terrible :-(, and worst of all I'm a newbie. Anyone have a idea how to do it? There are some apache libs for it, but as I mentioned documentation is very weak. Here is reference to this class. best, Pat...

Android: Can't figure how to use setImeActionLabel

What I want to do is change the default "Done" label that appears in the virtual keyboard. Here's what I've tried without any luck: mSearchInput.setImeOptions(EditorInfo.IME_ACTION_DONE); mSearchInput.setImeActionLabel(getString(R.string.search_action_label), EditorInfo.IME_ACTION_DONE); I am able, however, to handle a click on that b...

update Android ListActivity when list data changes

i want to know how to refresh the ListActivity when i change/add data to the list wich is dispayed. i first thougt the ListAdapter would know when the list is changed but when i add elements to the list there is no update, only when i close the activity and reopen it i see the changes. so i searched for any update() refesh() or somethin...

How can i optimize this dialog code for Android ?

I want to have a dialog containing 3 views 1. title with black background 2. some body text white background 3. a line with 2 buttons with gray background. The problem is that i want the background color of the body to be WHITE, but even my view has set backgroundcolor to WHITE, there seems to be some margins at top and bottom of the bo...

Android: How to overlay-a-bitmap/draw-over a bitmap?

I have two questions actually: Is it better to draw an image on a bitmap or create a bitmap as resource and then draw it over a bitmap? Performance wise... which one is better? If I want to draw something transparent over a bitmap, how would I go about doing it? If I want to overlay one transparent bitmap over another, how would I do i...

Android: Loading data and then notifying an Activity? Also documented a failed approach!

I just tried a stupid approach and it crashed my app... Basically I have an activity that has three tabs (containing three activities). Each of the tabs gets its input from an xml file downloaded off the net. Everything is fine but when I start my app, it has download the xml file and there's a "wait" time for this. I managed to get aro...

Parsing JSON in java

I'm trying to parse JSON in android but am having trouble with accessing sub children of an object. I am trying to extract augment from the following, {"augment-list": { "time": "12:01", "channel": "channel1", "augment": [ {"id": "123", "name": "here", "x": "5", "y": "10", "orientation": "up", "content": "some stuff"}, ...

Android - JNI guidelines

I want to incorporate small, lean and mean C-based parser into my Android project. I've done JNI programming in the past but not any type of native (C) development on Android. My plan is to compile C lib into SO and create JNI wrapper around it which I'm going to use in my app. Is this how it can/should be done? Second and most important...

Returning a memory mapped InputStream from a content provider?

The the client side of a content provider consumer I can do something like this, to get a proper InputStream for reading the picture: InputStream is = getContentResolver().openInputStream(pictureUri); It is a nice API, and will on the server side, the actual content provider result in a call to: public ParcelFileDescriptor openFile(U...

getting an error while upgrading my application in android market

Whenever I try to upgrade my application in android market I am getting this error: "The apk must be signed with at least one certificate in common with the previous version" and I have lost my previous keystore. Any help will be appreciated ...

Android: How to communicate and exchange objects with a Local Service

So far I've a class for a simple local service. What I want to do is to send requests to this local service from different activies in my application. Depending on the parameters of these requests the service will connect via HttpClient to a webserver and receive a JSONObject and return it to the activity. All the HTTP communication is a...

Android: this.getApplication() returns NULL pointer

I'm running the following line in an Activity, which is within the same application, but in a different package: AppObject appObj = (AppObject)this.getApplication(); // FYI: AppObject is my extension class of Application. It returns only a null pointer, while when I move it to the "main" package and run it from there it returns the ap...

Android color picker - updating color array

Hi all, I'm trying to create a color picker for Android that looks like a minimalistic version of Gimp's. So, it has a hue slider and a rectangle with saturation/value variants of a color chosen in hue slider. Question: what is the best way to create the rectangle? Right now, I'm creating an 200x200 array of pixels, but it takes ~5sec ...

How to start a new application on Android

How can I start a new application on Android? I have done a new applications NewHomeScreen and Hello and on NewHomeScreen I wrote this code. @Override public void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.main); Intent mainIntent = new Intent(this,Hello.class); startActivity(mainIntent); } ...

Include database data when exporting an Android application

I export my application to .apk file, sign it then install it. But when I run my App, it displays an error because there's no data in my database. The database was created as a new one when I installed the application, so all the data were lost! How can I include database data when exporting an Android application? ...