pranay
pranay

Reputation: 2369

Unable to view map on the android emulator

i am unable to view maps on the emulator. I am under proxy internet connection, I also set the proxy via GUI and also have set api Key alongwith the perimissions and library.

here's my code:

package com.example.MyMapActivity;
import org.apache.http.HttpHost;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.impl.client.DefaultHttpClient;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;

public class MyMapActivity extends MapActivity {

private MapView mapview;
private MapController mapcontroller;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    DefaultHttpClient client = new DefaultHttpClient();

    String proxyHost = android.net.Proxy.getHost(this);
    if (proxyHost !=null) {
      int proxyPort = android.net.Proxy.getPort(this);

      HttpHost proxy = new HttpHost("*********", ***);

      client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
    }
    //mapview = (MapView)findViewById(R.id.mapview);
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    // this method must return true if your app returns driving directions , else return false
    return false;
}

}

The Layout file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView 
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
 android:apiKey="***********">     </com.google.android.maps.MapView>

The mainfest file

<?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.MyMapActivity"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <uses-library android:name="com.google.android.maps"></uses-library>
    <activity android:name=".MyMapActivity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>
<uses-sdk android:minSdkVersion="7" />

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

Upvotes: 1

Views: 2654

Answers (3)

userX
userX

Reputation: 59

I faced the same problem and after a long time I found that I made a mistake in one digit while copying the md5, so the generator produced me a wrong api key. My suggestion is to make sure first that you have copied the correct md5.

Upvotes: 2

Al Sutton
Al Sutton

Reputation: 3924

If the emulator does not have Google Maps installed on it you can't use MapView or any other maps related activity.

You need need to make sure you create an emulator image which has the Google APIs available.

Upvotes: 1

Janusz
Janusz

Reputation: 189504

If the mapview is displayed but no maptiles are loaded it could be this bug ( Google Maps fails via mandatory web proxy) that is reported in the bug database from google. Read all the information about the issue carefully. It is very possible that this is an error on your side that you will never discover because you think it is googles fault.

Test the app somewhere without a proxy to confirm that it is working there.

Upvotes: 0

Related Questions