Issue
I'm trying to built an android application that shows the location in a map view. This is my code:
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.overblog.R;
public class EditMapSectionActivity extends MapActivity{
private MapView _mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_section_map_activity);
_mapView = (MapView) findViewById(R.id.map_view);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/fragment_background_color" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="@dimen/scroll_view_padding_left"
android:paddingRight="@dimen/scroll_view_padding_right"
android:paddingTop="@dimen/scroll_view_padding_top" >
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/search_for_location" />
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/section_padding_top"
android:apiKey="0t8UnajIfX1hZH27u-DCH40YuglmW1-1U51_wQA"
android:background="@drawable/default_image_background"
android:clickable="true" />
<CheckedTextView
android:id="@+id/check_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:text="@string/section_cover_picture" >
</CheckedTextView>
</LinearLayout>
</ScrollView>
I am sure of my debug apiKey because i used it in other applications, i also sure that i added internet permission to my manifest.xml
When i run my app my mapView doesn't load the map.
I checked my logcat, i got this warning:
10-04 17:33:10.511: W/MapActivity(21034): Recycling dispatcher android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher@40c5edd0
Do anyone know what this warning mean?
Solution
My suggestion is to remove everything extra you have, verify that it is working at it's simplest state and then if you need the background, margin, etc declarations in your xml then insert them in one at a time and run your application. This will allow you to narrow down the blank maps and warning message culprit.
Assuming you have a valid API key I know the following code works:
The xml side:
<com.google.android.maps.MapView
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="InsertYourAPIKeyHERE"
android:clickable="true"
android:state_enabled="true" />
The java side:
public class EditMapSectionActivity extends MapActivity {
private MapView _mapView;
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_section_map_activity);
_mapView = (MapView) findViewById(R.id.map_view);
}
}
The manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package=""
android:versionCode=""
android:versionName="" >
<!-- Network Permissions -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:alwaysRetainTaskState="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".EditMapSectionActivity"
android:label="@string/app_name"
android:noHistory="false" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Answered By - jnthnjns
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.