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. SOLD WTS: Acer #aer Liquid E Batangan

Permisi,
mau update aja sudah sold to Mr. B.
Terimakasih yang udah japri :)

Enya


2010/12/11 Enya Anggia <enya.dr...@gmail.com>


-- 
===============
"

2. [WTS] Droid 2

Dear all members,

Want To Sell Droid 2 kondisi 80%, kelengkapan Hape plus charger nya
ajah ^_^

Udah ada nomor smart dengan paket internet unlimited ;)

Harga nya yang terbaik diatas 3,3 juta

Terima kasih momod untuk b/w nya

--

-- 
===============
"

3. Problem with the new SDK r08 on linux

4. review froyo official di galaxy 5

5. Annoyed by not having any information on my users!

6. Need for speed shift dari samsung apps utk gtab gak bisa download

7. ddms problem ping emulator standalone? unable to set gps geo fix