android

activity to ask user to select point on map?

in my app, i'd like to have the user select a couple points on the map. ideally i'd fire an intent to trigger an activity with result each time they want to add a point, and in a local map view on my main activity, display all the selected points. later, i'll do something with all the points using overlays. i didnt see this exposed fr...

Calling an inputMethod's method when a BroadcastReceiver gets called

I added a BroadCastReceiver to my application. I want to call my inputMethod's method but I can't find a way to access it's instance. I read I can get an InputMethodManager by: InputMethodManager manager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); but I couldn't find a way to get the the InputMethod...

Instrumentation testing

I have written an instrumentation test case,When I try to run this,I got the following error java.lang.RuntimeException: Exception during suite construction at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:239) at java.lang.reflect.Method.invokeNative(Native Method) at a...

Is there an Android utility for storing a static map?

I've got a common use-case wherein a user selects one item out of many (say, on a spinner or autocomplete list), then enters the data. For example, let's say the user selects a country. Ultimately, the data I want is the country code, not the country name; but the users will want to select based on name, not code. To put it another wa...

How to discover memory usage of my application in Android

I would like to know how I can find the memory used on my Android application, programmatically. I hope there is a way to do it. Plus I would like to understand how to get the free memory of the phone too. ...

Android Layout question

My app has 5 different relative layouts that it can switch between by using a set of buttons that is at the bottom of the screen. 3 of the layouts contain only TextViews and ImageViews. The other 2 both have a ListView in them. On the 2 views that contain lists when the soft keyboard appears the buttons that are along the bottom move up ...

Android SSL socket blocks on read while changing connection

I assume that when I do a read on the inputstream, it blocks until it gets more data to read. I also assume that when the connection is closed, the read throws an IOException. The problem is that sometimes when I change the connection from carrier to WiFi or from WiFi to carrier, the read just gets stuck and never throws the IOException...

Android: how to set Wifi settings to access Internet connection in Android simulator?

Hello, I am working on an Android application which does http request and download contents etc. I want to test such cases on Android Simulator. I am using Android SDK 1.6. As my computer(Mac OS X) has Internet connectivity via Wifi, i'm trying to activate Wifi connectivity in Android Simulator as well, so that my code can get data conn...

Determine when the Android GC runs

Does anyone know if there is a way to identify (in code, not LogCat) when the GC has run? Perhaps an intent is fired? I could analyze the LogCat output, but it would be ideal if I could determine when the GC has run from my code. ...

How to create multiple instances of an activity?

I want to create multiple instances of an activity in the same process. Should I use FLAG_ACTIVITY_NEW_TASK flag like the code below? Intent i = new Intent(); i.setClass(this, A.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); This code is executed in...

Problem With My Android Service Please Help!

All I want to do is simply control background music in my app through a service so I am able to start it and stop it from any activity. I have everything set up perfectly when I tell the service to Toast when it is started and destroyed but as soon as I put the media playin in there instead It starts fine and starts playing the music bu...

Robust+easy way to save/restore Android app instance state

In Android, you need to implement the following Activity methods so your application can be restored to its previous state if the OS decides to destroy then recreate your activity: public void onSaveInstanceState(Bundle savedInstanceState) public void onRestoreInstanceState(Bundle savedInstanceState) The examples I've seen of implemen...

Android Service controlling MediaPlayer

All I want to do is simply control background music in my app through a service so I am able to start it and stop it from any activity. I have everything set up perfectly when I tell the service to Toast when it is started and destroyed but as soon as I put the media playin in there instead It starts fine and starts playing the music bu...

Which Android platform and API to target?

I'm just about to launch my first Android app, and it runs on the Android 1.1 platform, API Level 2, but is this what I should officially sign and launch the app as? Does it affect performance at all or is it simply for Android to know which devices it works on? The only problem I see is that I can't specify <supports-screens> in the M...

How to change orientation of xml "layout" area in Eclipse

The xml files that contains the Activity layouts can be rendered by Eclipse. How do I get that Eclipse screen area to have vertical orientation, not horizontal (inside Eclipse - it correctly shows as vertical in the emulator)? Peter ...

Android Instrumentaion: How do I go back to a previously launched Activity?

Hello, I'm currently running automation tests using an app that uses multiple Activity for displaying each screen. Is there anyway to go back to a previously launched Activity while running an Instrumentation test? Currently, when I use sendKeyDownUpSync( KeyEvent.KEYCODE_BACK);, this forces my test to exit, rather than go back to the ...

How can I swap LinearLayouts from XML during runtime (Android)?

Hi, I am trying to create an option in my code to change layouts using preferences. I already have the two layouts created in XML, but I can't figure out how to swap between the two during runtime. I would like to cause it to check during onResume() since it is called directly after returning from the Preferences screen and when startin...

Different aapt behavior for subdirectories between 1.6 and 2.1?

The scene: I have a directory structure like the following: mkdir -p foo/bar touch foo/bar/test.txt What I want to do is to add test.txt to a .apk under the directory foo/bar, so that uncompressing or listing the apk returns the same directory structure. This worked fine under the 1.6 SDK: aapt add test.apk foo/bar/test.txt I co...

Android launch mediplayer for videos from a webview?

I have a webview, if the user clicks on a link, it opens in the same webview (I controll that with shouldOverrideUrlLoading()) but if it is a video link (mp4, 3gp) it does not launch the media player to reproduce the video (as it does in the normal browser app). How o force the media player to launch when a video link is clicked inside a...

How to work with large bitmap. Rotating and inserting to the gallery.

I need to take a picture with the camera and, if depending on the picture size, rotate it before saving it into the gallery. I'm using Intent imageCaptureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); imageCaptureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(imageCaptureIntent, IMAGE_CAPTURE...