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. How To Custom Horizontal Scroll?

I've read all over and everyone one asks how to achieve a horizontal
scrolling on a LinearLayout.  It's really bad that no one has a
solution to this issue...

My question is;

1. How do you use Scroller class? do I have to extend the class?
2. How could I track finger location movement on a layout?

A little hard coded Horizontal moving of a Layout.

Move Item Horizontally:
LinearLayout tbl = (LinearLayout)findViewById( R.id.MenuBarLayout );
tbl.scrollTo(40, 0);

Hopefully someone can point me to the right direction...

Thanks,
Moto!
--~--~---------~--~----~------------~-------~--~----~

2. WebView for "Form" based "Local AJAX" application

Hi,
I'm thinking of using WebView as a container for "Form" based
JavaScript+DHTML applications. This is simple fill-out-forms like you
have on the web, but now on mobile - like for note taking, order
taking, and the like.

This is to allow web developers to build the bulk of the application -
Javascript will perform validation, computations, etc.

On the Java side, I only need to implement database CRUD operations,
and a ListView to scroll over the forms.

To minimize the learning curve on the JavaScript side, I've been
thinking on how to emulate AJAX calls so that the web developers don't
need to learn new methods to call on the JavaScript-Java bridge. Of
course this isn't possible using XMLHttpRequest, so I'm thinking of
adapting JQuery or other Javascript libraries for this purpose.

Any thoughts on this?
--~--~---------~--~----~------------~-------~--~----~

3. Native music playlist format

4. When can the bug in the bug report be fixed?

5. Interesting Question

6. compile 2.6.27 goldfish branch failed

7. file transfer using usb to windows pc from android kernel