开发者

Getting error when changing from main to other activity - Android

I have an application using the Google maps - u开发者_高级运维ntil the moment it works fine. But now when I want to click a button in order to add functionality over the map I have problems. I managed to visualise the button on the screen, also it works on click - it shows a toast correctly. But my aim is to start a new activity (having his own layout) - looking and reading tones of tutorials and stuff here is what I have :

        //the Add Button in the upper right corner
    Button addBookmark = (Button) findViewById(R.id.Button);
    addBookmark.setOnClickListener(new View.OnClickListener() 
    {
        @Override
        public void onClick(View mapView) {

            Intent addBookmarkIntent = new Intent(GoogleMapsApp.this, LocationBookmaker.class);
            startActivity(addBookmarkIntent);                                           
        }
    });        

Also I've edited the manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      ...

        <activity android:name=".LocationBookmarker"
        android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>

        ...

</manifest>

No matter what I try I always get the "The Application GoogleMapsApp (process google.maps.app) has stopped unexpectedly. Please try again." with the only "Force close" option.

I've been trying since two days now - and in a lot of examples in the Internet other say it should be working like this. I cannot see where could be my mistake. Maybe in the starting of the intent, or the manifest or where...?


According to the exception, the class it's looking for is 'LocationBookmaker', but in your manifest you have 'LocationBookmarker' (notice the 'r'). That may be your problem.


I don't know what the problem you get is but a tip is to run the "Dalvik Debug Monitor" (ddms) on your computer, with that you can capture all exceptions in your application and see exaclly what the error is (most of the time).

You find the ddms in the tools directory of your android installation, if you run windows its a bat file, ddms.bat, that you just run from cmd.

/Viktor

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜