views:

557

answers:

3

I'm using IntelliJ IDEA 9 (9.0.1) to create a simple map application (or at least trying to). I'm using Android 2.0 with Google API's 2.0.

Manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.example">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MyActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <activity android:name=".disaster"/>
        <activity android:name=".map" android:label="@string/app_name"  android:theme="@android:style/Theme.NoTitleBar"/>
        <uses-library android:name="com.google.android.maps" />
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

Class:

public class map extends MapActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);

        Button saveMe = (Button) findViewById(R.id.backBtn);
        saveMe.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent myIntent = new Intent(view.getContext(), MyActivity.class);
                startActivityForResult(myIntent, 0);
            }
        });

    }

    @Override
    protected boolean isRouteDisplayed() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }
}

View:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/wall"
    >
        <View android:id="@+id/mv"
       class="com.google.android.maps.MapView"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:enabled="true"
       android:apiKey="08zxVQUd22SOeAuv8AEMS5hBAeOdll4OzDrNYpQ"/>

       <Button android:id="@+id/backBtn"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:text="@string/backBtn"/>

</LinearLayout>

This just gives me an empty screen.

What I'm doing wrong?

Edit: clarified my OP.

A: 

You have to include a Maps API debug key to get map content displayed. http://code.google.com/android/add-ons/google-apis/maps-overview.html

sadboy
I'm using the second code I posted and I filled in a key.I just replaced it with myKey here to be on the safe side.I probably should have mentioned that.
I haven't signed the application myself, but according to http://developer.android.com/intl/zh-TW/guide/developing/other-ide.html#DebugMode that should happen automatically.Is there a way to check if this has actually happened?
`jarsigner -verify -verbose my_application.apk` will tell you if your app is signed
Mike
A: 

Make sure you have permissions to go to the internet and to access locations in your AndroidManifest.xml:

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

Edit:

Ok it seems the case is sensitive so changing from:

<View android:id="@+id/mv"

to

<view android:id="@+id/mv"

should display your map.

ccheneson
Hello, thank you for thinking along.I've already set android.permission.INTERNET, and right now even just displaying the map isn't working, let alone using the mobile's GPS location. So I'm first trying to get the former to work.
Can you update your OP with your activity and maybe the full layout of your map xml?Also you need to set an id in your mapview (the com.google.android.maps.MapView example you gave doesnt not have one and you will need to reference it from within your activity)
ccheneson
I've updated my starting post, hopefully it's clearer now.The map is a view I call from my application menu. (well I call the map class which starts the view)
Have you tried using <com.google.android.maps.MapView instead if <View .. ? I tried using the View tag (with the class) but it didnt work (black screen) but it did with <com.google.android.maps.MapView
ccheneson
See my edit about <view instead of <View
ccheneson
Damn, I just really swore for over 5 minutes.I know that all the examples use view but intellij marks it as not allowed here so I looked through the list and saw that View was in there so I used that. I did the change to view, ignored the error and compiled it and now it's showing.Thank you.
A: 

Okay, if in IDEAJ than it depends upon that Android plugin whether the debug key signing happens automatically..check plugin docs along with your build file as you might have to add a debug key sign target

Fred Grott