问题描述
我已经创建释放键为我application.But它不显示map.What做我错了,我已经通过项目 - >导出 - 点击右键>给予ALIAS_NAME创建释放钥匙? - > ......像通过使用的Keytool。that.Then,我得到了释放key.i用它在我的XML。
我的code:
公共类SampleMapActivity扩展MapActivity {
图形页面myMapView = NULL;
MapController myMC = NULL;
GeoPoint对象的GeoPoint = NULL;
双纬度= 12.937875,东经= 77.622313;
/ **第一次创建活动时调用。 * /
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.main);
myMapView =(图形页面)findViewById(R.id.myGMap);
的GeoPoint =新的GeoPoint((int)的(纬度* 1000020),(int)的(经度* 1000020));
myMapView.setStreetView(真正的);
myMC = myMapView.getController();
myMC.setCenter(GeoPoint对象);
myMC.setZoom(15);
myMapView.setBuiltInZoomControls(真正的);
myMapView.displayZoomControls(真正的);
}
@覆盖
保护的布尔isRouteDisplayed(){
返回false;
}
公共布尔的onkeydown(INT键code,KeyEvent的事件){
如果(键code == KeyEvent.KEY code_I){
myMapView.getController()setZoom(myMapView.getZoomLevel()+1);
返回true;
}否则,如果(键code == KeyEvent.KEY code_O){
myMapView.getController()setZoom(myMapView.getZoomLevel() - 1)。
返回true;
}否则,如果(键code == KeyEvent.KEY code_S){
myMapView.setSatellite(真正的);
返回true;
}否则,如果(键code == KeyEvent.KEY code_M){
myMapView.setSatellite(假);
返回true;
}
返回false;
}
}
XML:
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
>
< com.google.android.maps.MapView
机器人:ID =@ + ID / myGMap
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:启用=真
机器人:可点击=真
机器人:apiKey =0GNnbje3crS0ZuqJfAFnJjO8zNPYy9OqNzHS2Aw
/>
< / LinearLayout中>
让去获取MapAPIKey。
1)如何创建密钥库
项目>>出口>> ExportAndroidApplication>>下一页>>创建新的密钥库(记住密钥存储区路径)>>填写所有详情>> ...等等
现在你的密钥存储和的.apk创建。
2)如何获得证书的指纹(MD5)
$的keytool -list -alias ALIAS_NAME -keystore我释放,key.keystore
有关详细去这里
现在你有指纹等为
证书指纹(MD5):94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98
3)如何获得MapApiKey 点击此处并粘贴MD5,然后U将得到MapAPIKey。使用此键在应用程序中。
4)测试
创建新的APK使用该密钥库和检查。
I've created Release key for my application.But It doesnt show map.What did i wrong on that?i've created release key by Right click of project->Export->Giving alias_name->...like that.Then by the use of Keytool.,i got that release key.i used it on my xml.
My code:
public class SampleMapActivity extends MapActivity {
MapView myMapView = null;
MapController myMC = null;
GeoPoint geoPoint = null;
double latitude = 12.937875, longitude = 77.622313;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myMapView = (MapView) findViewById(R.id.myGMap);
geoPoint = new GeoPoint((int) (latitude * 1000020), (int) (longitude * 1000020));
myMapView.setStreetView(true);
myMC = myMapView.getController();
myMC.setCenter(geoPoint);
myMC.setZoom(15);
myMapView.setBuiltInZoomControls(true);
myMapView.displayZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_I) {
myMapView.getController().setZoom(myMapView.getZoomLevel() + 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_O) {
myMapView.getController().setZoom(myMapView.getZoomLevel() - 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_S) {
myMapView.setSatellite(true);
return true;
} else if (keyCode == KeyEvent.KEYCODE_M) {
myMapView.setSatellite(false);
return true;
}
return false;
}
}
xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/myGMap"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
android:clickable="true"
android:apiKey="0GNnbje3crS0ZuqJfAFnJjO8zNPYy9OqNzHS2Aw"
/>
</LinearLayout>
lets go for get MapAPIKey.
1)How to create KeyStore
Project >> Export >> ExportAndroidApplication >> Next >> Create New Keystore (Remember Keystore Path) >> Fill All Detail >> ...etc
Now your keystore and Apk is created.
2)How to get Certificate fingerprint (MD5)
$ keytool -list -alias alias_name -keystore my-release-key.keystore
for more detail go here
Now you got fingerprint like as
Certificate fingerprint (MD5): 94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98
3)How to get MapApiKeyclick here and paste your MD5 then u will get MapAPIKey.Use this key in your application.
4)Test
create new apk using this keystore and check..
这篇关于地图显示,在Android的发布重点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!