1

Friends!

I can't call MapActivity from other activity :

Intent nextScreen = new Intent(getApplicationContext(), MapScreen.class); 
startActivity(nextScreen);

Where MapScreen.class is a public class MapScreen extends MapActivity

the error message is:

03-20 11:00:38.757: E/AndroidRuntime(31450): FATAL EXCEPTION: main
03-20 11:00:38.757: E/AndroidRuntime(31450): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.router.android/com.router.android.MapScreen}: java.lang.NullPointerException
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2081)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2106)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread.access$700(ActivityThread.java:134)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1217)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.os.Handler.dispatchMessage(Handler.java:99)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.os.Looper.loop(Looper.java:137)
03-20 11:00:38.757: E/AndroidRuntime(31450): at android.app.ActivityThread.main(ActivityThread.java:4856)
03-20 11:00:38.757: E/AndroidRuntime(31450): at java.lang.reflect.Method.invokeNative(Native Method)
03-20 11:00:38.757: E/AndroidRuntime(31450): at java.lang.reflect.Method.invoke(Method.java:511)
03-20 11:00:38.757: E/AndroidRuntime(31450): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
gsb
  • 5,520
  • 8
  • 49
  • 76

1 Answers1

1

Open MapScreen class from another activity is correct with

Intent nextScreen = new Intent(getApplicationContext(), MapScreen.class); 
startActivity(nextScreen);

or

Intent nextScreen = new Intent(this, MapScreen.class); 
startActivity(nextScreen);

I think the problem is in your MapScreen class, must have a onCreate() method.

public class MapScreen extends MapActivity{

protected void onCreate(Bundle arg0) {

like this example class: http://depaul-android-app.googlecode.com/svn/tags/0.0.1/src/edu/depaul/android/activities/MapScreen.java

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • I think that it works for googlemaps for mapquest... because continue the same error message... **public class MapScreen extends MapActivity {** @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); – Rod Barrientos Mar 21 '14 at 06:12