Activity not launching MapActivity

by Josh » Sat, 08 May 2010 12:23:58 GMT


Sponsored Links
 ello

I have a TabActivity that loads in 3 activity classes. In those
Activity classes I have a button and an OnClickListener that tries to
open a MapActivity class. When I click the button I get a force close
and error.

Uncaught handler: thread main exiting due to uncaught exception
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.company.Name/com.company.Name.LocationMap}:
java.lang.NullPointerException

I have searched to find an example of an Activity class launching a
MapActivity class but cannot find one. If I swap out my MapActivity
class with a Activity class it works.

Here is my Activity Class that has the listener.

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_tab);

Button btnMap = (Button) findViewById(R.id.btnMapview);
btnMap.setOnClickListener(mMapListener);

}

private OnClickListener mMapListener = new OnClickListener() {
public void onClick(View v) {
Intent mapIntent = new
Intent(getApplicationContext(),LocationMap.class);
startActivity(mapIntent);

}
};

Here is my MapActivity class

protected boolean isRouteDisplayed() {
return false;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mapView = (MapView) findViewById(R.id.myMapView);
mapView.setBuiltInZoomControls(true);


mc = mapView.getController();
String coordinates[] = {"40.750386", "-73.976773"};
double lat = Double.parseDouble(coordinates[0]);
double lng = Double.parseDouble(coordinates[1]);

p = new GeoPoint(
(int) (lat * 1E6),
(int) (lng * 1E6));

mc.animateTo(p);
mc.setZoom(17);
mapView.invalidate();

}

And my Manifest

<uses-permission android:name="android.permission.INTERNET" />

<application android:icon="@drawable/logo" android:label="@string/
app_name">
<activity android:name=".Splash"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".Locations"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"></
activity>

<activity android:name=".LocationNewYork"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
</activity>


<activity android:name=".LocationSeattle"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"></
activity>

<activity android:name=".LocationMap"



Activity not launching MapActivity

by TreKing » Mon, 10 May 2010 05:39:54 GMT


 



This error should also tell you exactly what line the null pointer exception
is happening, which will tell you what's null, which will tell you what the
problem is.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
 http://sites.google.com/site/rezmobileapps/treking 

--


Sponsored Links


Other Threads

1. Recommendations for variable length ListBox

All of the examples of the use of ListView and similar controls that I
can find assume a fixed number of field names coded into @strings or
similar, and retrieved through R.layout functions.

I want to dynamically create ListViews, Linear Layouts, Spinners etc
of variable length, and contents determined at run time.

I assume this is possible. Various appraoches occur to me:

Extend ListView with a custom creator that pre-populates with the
runtime determined field names. 
http://developer.android.com/resources/tutorials/views/hello-listview.html
gives a hint on how to do it, whilst not directly addressing the
question.

I could try and take out the requirement to go through R.layout, and
directly reference some other data structure

And some others.

However, this must be a very common design pattern, can anyone tell me
the recommended approach for allocating the number of items in (say) a
List View and their content at runtime ?

Thanks


Peter Webb

-- 

2. API to Install Certificate

Hi All,
  Is there any API to install CA Certificates(.cer or .p12 files) from
File System/SD card.
  I am able to do it manually but i would like to automate the same
via a Widget that will Browse SD card for certificates and Install
them on selection.


Thanks and Regards,
Jimi<Shashi Kiran G M>




-- 

3. Screen capture from video stream

4. Smooth scrolling within a custom view - how to?

5. Can startActivityForResult be called from within InputMethodService?

6. queryBroadcastReceivers does not return receivers registered by registerReceiver()

7. ContactsContract.Contact Not fully Aggregated