我很清楚如何获得用于Google Maps v2库的调试密钥,以及如何获取发布密钥.目前我的清单文件的相关部分如下所示:
<!-- Debug -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="[my debug key here]"/>
<!-- Release
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="[my release key here]"/>
-->
Run Code Online (Sandbox Code Playgroud)
相关密钥未注释,另一个注释.
任何人都可以指出一种舒适的方法来避免每次需要调试而不是发布版本时对这些清单文件进行注释/取消注释的烦恼吗?
在我的应用程序中,我有一个派生自ExpandableListActivity的类.当我滚动内容,然后更改手机方向或编辑项目,然后返回列表时,不保留原始列表位置.我尝试了两种解决方案,类似于我最近成功使用ListActivity派生类的解决方案.
解决方案1:
protected void onRestoreInstanceState(Bundle state) {
super.onRestoreInstanceState(state);
mListState = state.getParcelable(LIST_STATE);
}
protected void onResume() {
super.onResume();
loadData();
if (mListState != null)
getExpandableListView().onRestoreInstanceState(mListState);
}
protected void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
mListState = getExpandableListView().onSaveInstanceState();
state.putParcelable(LIST_STATE, mListState);
}
Run Code Online (Sandbox Code Playgroud)
解决方案2:
protected void onRestoreInstanceState(Bundle state) {
super.onRestoreInstanceState(state);
mListPosition = state.getInt(LIST_STATE);
}
protected void onResume() {
super.onResume();
loadData();
getExpandableListView().setSelection(mListPosition);
}
protected void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
mListPosition = getExpandableListView().getFirstVisiblePosition();
state.putInt(LIST_STATE, mListPosition);
}
Run Code Online (Sandbox Code Playgroud)
两种解决方案都无效.我也尝试将两种解决方案结合起来,这在我编辑项目并返回列表时起作用,但是当我改变手机方向时它不起作用
任何人都可以建议一个实现目标的好方法吗?
我在iOS 4上使用iPhone上的mapkit.我使用自定义叠加层和自定义叠加视图,在地图上绘制形状.目前,形状只是矩形,但我正在计划更复杂的东西.这就是我没有使用MKPolygon覆盖类型的原因.这是我的叠加视图绘制方法的代码:
-(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context
{
// Clip context to bounding rectangle
MKMapRect boundingMapRect = [[self overlay] boundingMapRect];
CGRect boundingRect = [self rectForMapRect:boundingMapRect];
CGContextAddRect(context, boundingRect);
CGContextClip(context);
// Define shape
CGRect shapeRect = CGRectMake(0.5f, 0.5f, boundingRect.size.width - 1.0f, boundingRect.size.height - 1.0f);
// Fill
CGContextSetRGBFillColor(context, 0.5f, 0.5f, 0.5f, 0.5f);
CGContextFillRect(context, shapeRect);
// Stroke
CGContextSetRGBStrokeColor(context, 0, 0, 0, 0.75f);
CGContextSetLineWidth(context, 1.0f);
CGContextStrokeRect(context, shapeRect);
}
Run Code Online (Sandbox Code Playgroud)
问题是矩形被正确填充(因此看起来它们的边界矩形被正确设置),但它们不会被描边.有人可以帮忙吗?谢谢!
我正在尝试发布iPhone应用程序; 它不是第一个,我已经在过去发表了其他文章.所以我在第一个和第二个表单中输入了所需的信息,然后填写了大的第三个表单,您还可以上传图标和屏幕截图.好吧,我在上传屏幕截图之前按了"保存"按钮,因为我注意到我没有可用的视网膜4截图,并且必须先制作它.
为什么我按"保存"?好吧,我只是想确保我输入的所有信息都不会丢失.
合理地,我收到有关丢失屏幕截图的错误消息.
过了一段时间我上传了截图,但是当我再次尝试保存时,我得到了一个通用错误,例如"出现了错误,联系支持".也许我的会话在此期间已经过期了???
好的,所以我按"取消".我回到初始屏幕,列出了我的应用程序.没有新的迹象,所以我想我必须重新输入一切.
令人惊讶的是,当我填写第一个表单时,我收到一条错误消息:
The Bundle ID you entered has already been used
Run Code Online (Sandbox Code Playgroud)
我想我将不得不选择一个不同的捆绑ID ...听起来很疯狂,只是无法相信它...任何建议?
我想使用Google Maps API v2,但仅在后台显示一个虚拟地图。这是我正在使用的PNG文件的示例,称为“ dummy_map_tile.png”。我将其放置在资产文件夹中名为“ images”的目录下。尺寸为256x256像素。还尝试了JPG类似文件。

这是我的虚拟地图图块提供程序的代码,当然应该可以离线使用:
public class DummyTileProvider implements TileProvider {
protected Tile mDummyTile = null;
public DummyTileProvider(Context context) {
InputStream inputStream = null;
ByteArrayOutputStream outputStream = null;
try {
String tileFilename = "images/dummy_map_tile.png";
inputStream = context.getResources().getAssets().open(tileFilename);
outputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[2048];
int count;
while((count = inputStream.read(buffer)) != -1)
outputStream.write(buffer, 0, count);
outputStream.flush();
mDummyTile = new Tile(256, 256, outputStream.toByteArray());
}
catch (IOException e) {
mDummyTile = null;
}
finally {
if (inputStream != null) …Run Code Online (Sandbox Code Playgroud)