android

Pause and Resume AsyncTasks? (Android)

I have an AsyncTask that acts as a countdown timer for my game. When it completes the countdown it displays the out of time end screen and it also updates the timer displayed on the screen. Everything works fine, except I need to be able to pause and resume this when the pause button in the game is pressed. If I cancel it and try to r...

android getAppWidgetIds failed, what wrong?

I want to use following code to get a widget id, but getAppWidgetIds always return an empty array, the num is always 0, what wrong? Thanks! public class test extends Activity implements OnTouchListener { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ..... AppWidgetM...

Are primitive types garbage collected in Android?

I know this may be a dumb question, but my background is more in c++ and managing my own memory. I am currently cutting down every single allocation that I can from one of my games to try and reduce the frequency of garbage collection and perceived "lag", so for every variable that I create that is an Object (String and Rect for example...

Eclipse thinks my project is an Android project - can I remove without starting over?

I created a project, probably as an Android project without thinking. I then did a lot of work bringing in source, etc. but it is not an Android target. However, when I start up Eclipse, it keeps popping-up a dialog reminding me that I have not established the Adroid device settings. How can I make it stop -- without restarting the wo...

It is possible to include layout and other resources in an Android jar?

I'm building a jar so that other developers can use the view I create in their Android applications. I'm wondering if it is possible to use a layout resource in my jar so I can build the layout of my view or if I need to build up my view programmatically. Similarly, can I include image resources in my jar file? ...

android : widget long press & movement handling in user activity.

hi, please suggest me a way to handle widget long press event & its movement in user defined home screen .i.e i have activity whose background handles the long click and then we can choose the approprait widget from the list ,but the problem is that i am not able to implement the long click on widget and its movement in my activity. for ...

Problem with sqlite database on android platform

hi all i am developing an application which uses sqlite db for storing records. I am developing this application on SDK 1.5.. when i test the application on 1.5 device it works good but when i try to run it on a 1.6 device i get a force close message with following logcat output: 03-19 09:31:35.206: ERROR/AndroidRuntime(224): Uncaught ...

Why are there so many floats in the Android API?

The default floating point type in Java is the double. If you hard code a constant like 2.5 into your program, Java makes it a double automatically. When you do an operation on floats or ints that could potentially benefit from more precision, the type is 'promoted' to a double. But in the Android API, everything seems to be a float f...

Using a MockContext inside a Java package not an Android Package.

I have moved most of my Android code into a separate Java project in Eclipse. I want to run some JUnit4 tests however I can't seem to get a MockContext working. I have extended MockContext() but have not done anything with it yet as I don't know what need to be done. At: private static MyMockContext context = new MyMockContext(); I...

Conditional restart on Activity onConfigurationChanged

I want to make an activity that allows orientation changes on some condition, but not otherwise. More exactly I want to prevent restarting the activity when a background thread is busy. I have put the configChanges attribute on the activity manifest, and onConfigurationChanged is called when the orientation changes. However I want to al...

How to create a split control like the one in the Browser's Address Bar? (Android)

I want to create a search box with the search button directly on the right of the EditText, without any spacing. Looks like the address bar on the internal Browser application. Is it possible or do I need to create it myself? ________________________________________ (_________EditText______________|_Button_) ...

Stuck on emulator screen in Eclipse with Android Development?

I've followed this tutorial: http://anandhansubbiah.com/blog/writing-your-first-android-application/, but no matter what I do, and what I change, when I run the app, all I see is the image below. Is there something I must press to start developing? Did I add starting code. I'm completely stumped... ...

How to invoke the getView method in the baseAdapter in Android from another WebService Bean?

The adapter in my code as follows, I extends the base adapter: @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder vHolder; // if (convertView == null) { vHolder = new ViewHolder(); convertView = mInflater.inflate(R.layout.home_item, null); vHolder.albumIcon = (ImageView) conver...

Using static variables in Android

Hi, In android, are using static variables a recommended practice? E.g, implementing a Singleton pattern in Java, I usually do: private static A the_instance; public static A getInstance() { if (the_instance == null) { the_instance = new A(); } return the_instance; } Also, when does this get cleaned up by the Andro...

How to establish a two-way communication between Activity and Service in different process?

Hi everyone, I'm working on establishing a two-way communication between an Activity and a Service which runs in a different process. Querying the process from the Activity is no big deal. But I want the process to notify the Activity on events. The idea behind it is this: the service runs independently from the actual app. It queries ...

android.content.ContentResolver.insert is original slow ?

I tested ContentResolver.insert with adding Contacts. Test Sample Count is 1000 count. But This is so slow . Why is it ? ContentResolver.insert() is very slow. Do you konw why is it so slow ? This is the very basic code adding Android Contacts list. If you know this problem, Please let me know. Test Android version is Android 1....

how to get the long & lat value of four corners in the mapview in android?

i working on map view. i want to put overlay item on the map view. that overlay items are all depends on currently showing map view and zoom level. how to get current map view's longitude and latitude of that four corner and how to analyze how many overlay item inside it. also we have to check thee zoom level.Any Idea? how to do it? ...

Trouble getting height of OverlayItem Drawable

Hey- I'm having some trouble getting a hold of the drawable a certain OverlayItem is using so I can calculate the height of it and properly offset the note that shows onTap. Here is my code to try to get that drawable: Drawable marker = item.getMarker(android.R.attr.state_focused); if (marker != null) int markerHeight = marker.getIntri...

Android - Avoiding a service to stop when pressing back button

Hi, I created and binded a service in an activity and I would like to know how I can avoiding the android application to stop when I press the back button. When the back button is pressed the onDestroy method is called and I unbinded the service in this method. I try to prevent it by taking care of the back button event and manually ca...

how to handle the visibility of the ItemizedOverlay in mapview in android?

i want set the visibility to itemized overlay in map view. if the zoom level is less than 10 i want to set visibility of overlay is GONE else VISIBLE. how to do that? and also cant set zoom level Listener. ...