Tag Archives: public-class

How to prevent ListView from updating while item is long pressed?

I have a ListView which is updated by some service sending intent. If update event arrives while I’m pressing some item in the ListView I get some weird behavior. The default orange rectangle in the pressed item disappears and some other item(s)’s text becomes darker (as if its item is being pressed)

Context null Pointer

I’ve been following this tutorial: http://developer.android.com/resources/tutorials/views/hello-mapview.html but in onTap mContext is throwing a NullPointerException.. anyone know why? Here’s my code.

How to put a Vector into an intent.extra?

Hi :-) , I’ve started to write a small app for android. It looks very nice, but there is one thing I don’t understand. I’ve created a new intent in the activity A and I’ve added a serialized vector intent.putExtra(“key”, vector)

Nullpointer Exception

I’ve got the following MapOverlay . The following line is throwing a NullPointer but I don’t understand why :S mapView.getProjection().toPixels(p, screenPts); could anyone help me out? public class Mapview extends MapActivity { GeoPoint p; MapView mapView; MapController mc; @Override protected boolean isRouteDisplayed() { return false; } public int icount = 0; MapController mapController; MyPositionOverlay positionOverlay; private LocationData tweets; public int start = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MapView myMapView = (MapView)findViewById(R.id.mapView); myMapView.setSatellite(true); myMapView.setStreetView(true); myMapView.displayZoomControls(false); mapController = myMapView.getController(); mapController.setZoom(17); myMapView.setBuiltInZoomControls(true); //Adding points here //—Add a location marker— MapOverlay mapOverlay = new MapOverlay(); List listOfOverlays = myMapView.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); myMapView.invalidate(); // Add the MyPositionOverlay positionOverlay = new MyPositionOverlay(); List overlays = myMapView.getOverlays(); overlays.add(positionOverlay); LocationManager locationManager; String context = Context.LOCATION_SERVICE; locationManager = (LocationManager)getSystemService(context); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setSpeedRequired(false); criteria.setCostAllowed(true); String provider = locationManager.getBestProvider(criteria, true); locationManager.requestLocationUpdates(provider, 2000, 10, locationListener); Location location = locationManager.getLastKnownLocation(provider); updateWithNewLocation(location); } private final LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { updateWithNewLocation(location); } public void onProviderDisabled(String provider){ updateWithNewLocation(null); } public void onProviderEnabled(String provider){ } public void onStatusChanged(String provider, int status, Bundle extras){ } }; private void updateWithNewLocation(Location location) { String latLongString =”"; TextView myLocationText; myLocationText = (TextView)findViewById(R.id.myLocationText); String addressString = “No address found”; if (location != null) { // Update my location marker positionOverlay.setLocation(location); // Update the map location

Android AsyncTask problem

Hi! I have a string that I want to update using AsyncTask class here is my code: public class MainActivity extends Activity{ private String str = “oldString”; /** Called when the activity is first created.

Starting a new activity

I’m relatively new to programming in general so be gentle =| I’m trying to start a new activity from a basic one that displays a couple of text inputs, a checkbox, and a button. When the button is pressed I want it to switch to the new activity. The code compiles but when I press the button in Android it simply crashes.

What kills an Android AsyncTask?

PrintStatusTask parses the contents of a gmail inbox looking for various items of interest to report on.

Create a simple, simple, Game Engine

Hello! I’m on my way with my first game, all design and that stuff are done, just coding left.

Why is the parcelable object null in receiving activity?

I am following the Parcelable example in the Android developer guide with the intention of having a more complex object that I send to different activities. Right now, my class is a wrapper of a String member. If I put the object in the intent and read it back from the Intent it reads as expected, however, on the receiver side, it is always null-pointer.

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