我收到了这个错误: ERROR/MapActivity(258): Couldn't get connection factory client
一切都很好,突然之间,怎么会发生这种情况?我知道我的api键很好,因为一个月我一直在使用它.怎么突然它没有向我展示地图活动,并在logcat中发布错误?
我正在为应用添加一些仅限棒棒糖的样式.
我想在Gmail中更改概述屏幕中的标题颜色:
我发现我能做到
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:colorPrimary">@color/my_favorite_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)
实现它,但我想只指定这种情况的颜色,就像我能做的那样:
<item name="android:statusBarColor">@color/my_favorite_color<item>
Run Code Online (Sandbox Code Playgroud)
是否有特定的属性来设置标题的颜色?
附带问题:图标和标题也可以更改吗?
我遇到了这个问题,谷歌的NavigationDrawer无法在地图上正确绘制,当我从屏幕一侧拉出它时,它被绘制在地图下而不是它上面,当它从已经打开时关闭它正确显示.
所述第一图片被关闭它,所述第二PIC被打开.这是在运行4.1的Galaxy S3上发生的,但在我的Galaxy nexus 4.2上没有问题.我ViewPager
和Map
前一段时间有类似的问题可以通过将地图放在FrameLayout
另一个框架布局上来修复,但那是在ICS之前的设备上.如果我不得不猜测这与硬件加速有关.
以下是 YouTube上的错误视频.
android google-maps google-maps-android-api-2 navigation-drawer
我尝试过使用Espresso测试框架并编写了一个简单的测试.
没有什么花哨的,只有这个代码:
onView(withId(R.id.login_button_stub)).perform(click());
Run Code Online (Sandbox Code Playgroud)
测试在Nexus 5设备和Genymotion与Android 5.0上运行良好,但在Android Emulator 4.x,5.0,Genymotion 2.3,4.x和LG G2与Android 4.x上运行失败.
在所有这些设备/模拟器/模拟器上,单击按钮并执行其操作(在我的情况下转到另一个屏幕).问题是它阻塞了perform
某些设备.这在60秒后以一个很好的例外结束:
android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id: com.vielengames.mock:id/login_button_stub'.
...
Caused by: android.support.test.espresso.AppNotIdleException: Looped for 3544 iterations over 60 SECONDS. The following Idle Conditions failed .
...
Run Code Online (Sandbox Code Playgroud)
请注意,没有关于哪些条件失败的信息.查看Espresso源代码,应该有一个以逗号分隔的问题列表.
这是完整的代码:TestCase.java.
和完整的堆栈跟踪:
I/TestRunner? android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id: com.vielengames.mock:id/login_button_stub'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:70)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:53)
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:185)
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87)
at com.vielengames.ui.NotLoggedOnTestCase.testLoggedOnAfterLoginClick(NotLoggedOnTestCase.java:19)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at …
Run Code Online (Sandbox Code Playgroud) 目前,我可以使用Android Google Maps API v2在Google地图中查看我的所有标记.
在地图中添加我的标记:
mapView.addMarker
(new MarkerOptions()
.position(aUsersLocation).
icon(BitmapDescriptorFactory.fromBitmap(aUserImage))
.snippet(My_VALUE_1)
.title(My_VALUE_2)
.hideInfoWindow();
Run Code Online (Sandbox Code Playgroud)
我有几个标记,并为每个标记的代码段和标题指定了几个值(My_VALUE_1和My_VALUE_2).当用户点击标记时,我需要这些唯一值,我将在onMarkerClick监听器中收到以下值:
@Override
public boolean onMarkerClick(Marker theMarker)
{
String aValue1 = theMarker.getSnippet();
String aValue2 = theMarker.getTitle();
theMarker.getPosition().latitude...
...
return false;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:当我将标题和标题值添加到标记时,当用户单击标记时,会显示infoWindow.
我需要隐藏标记的infoWindow.我尝试使用hideInfoWindow,但似乎无法正常工作.
请给我任何建议.
谢谢.
android google-maps android-maps android-mapview android-maps-v2
为了实现这一点,我觉得我只需要覆盖onMarkerClick
并检查点击标记的infoWindow是否已经打开,但令我惊讶的是clickedMarker.isInfoWindowShown()
总是返回false ...
我的代码:
@Override
public boolean onMarkerClick(final Marker clickedMarker) {
if(clickedMarker.isInfoWindowShown()) {
clickedMarker.hideInfoWindow();
System.out.println("was showing");
} else {
clickedMarker.showInfoWindow();
System.out.println("not showing");
}
}
Run Code Online (Sandbox Code Playgroud)
它总是告诉我infoWindow"没有显示"这是不对的......我可以通过保留参考来解决这个问题,userLastClickedMarker
但我想知道上面我做错了什么.
谢谢!
编辑:
我更改了代码以调试此问题:
System.out.println(clickedMarker.isInfoWindowShown());
if(clickedMarker.isInfoWindowShown()) {
clickedMarker.hideInfoWindow();
System.out.println(" showing");
} else {
clickedMarker.showInfoWindow();
System.out.println("not showing");
}
System.out.println(clickedMarker.isInfoWindowShown());
Run Code Online (Sandbox Code Playgroud)
我发现isInfoWindowShown()
在onMarkerClick方法中可以正常工作但不会正确"记住"它.而且我发现有人已经指出这是一个错误......
https://code.google.com/p/gmaps-api-issues/issues/detail?id=5408
我有一些存储在本地应用程序中的图像与某些上下文(如联系人)相关联.我正在使用直接共享(API 23+)ChooserTargetService
来显示这些可供选择,我希望ChooserTarget
实例Icon
填充这些图像.
所以我认为我可以android.support.v4.content.FileProvider
用于此(内部ChooserTargetService::onGetChooserTargets
):
val file = File(File(filesDir, "images"), imageFileName)
val contentUri = FileProvider.getUriForFile(this, "com.company.fileprovider", file)
val icon = Icon.createWithContentUri(contentUri)
Run Code Online (Sandbox Code Playgroud)
并在清单中:
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.mycompany.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_paths"/>
</provider>
Run Code Online (Sandbox Code Playgroud)
但问题是我得到了一个例外
05-10 16:06:09.100 32444-32444/android:ui W/Icon: Unable to load image from URI: content://com.mycompany.fileprovider/images/icon_dice.png
java.lang.SecurityException: Permission Denial: reading android.support.v4.content.FileProvider uri content://com.mycompany.fileprovider/images/icon_dice.png from pid=32444, uid=1000 requires the provider be exported, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1684)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:146)
at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:692)
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1147)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:984) …
Run Code Online (Sandbox Code Playgroud) android android-contentprovider android-support-library android-intent-chooser
我有问题访问地图的片段.getFragmentManager().findFragmentById(R.id.map))返回null.我不知道为什么.有什么问题?
谢谢!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tvNombreCentro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:tag="tag_fragment_map" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
并且在setContentView之后的活动中我尝试访问地图,但是我收到了一个异常
public class Mapa extends Activity {
private GoogleMap mMap;
private ActionBar ab;
private TextView tvNombreCentro;
private TextView tvTelefonoValor;
private TextView tvEMailValor;
private TextView tvWebValor;
private TextView tvDireccionValor;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapa_centro);
GoogleMap mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
}
Run Code Online (Sandbox Code Playgroud) 我可以使用一个简单的代码块自定义infoWindow的内容:
private GoogleMap mMap;
mMap.setInfoWindowAdapter(new InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
@Override
public View getInfoContents(Marker arg0) {
View v = getLayoutInflater().inflate(R.layout.custom_infowindow, null);
return v;
}
});
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#55000000" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="HELLO"
android:textColor="#FF0000"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但这只会改变内容,而不会改变infoWindow本身.它仍然保持白色,底部有一个小阴影,现在红色的HELLO文字可见黑色bg.我想将此默认infoWindow更改为透明的黑色矩形.我怎样才能做到这一点?
我目前正在使用地图,每10米我使用LocationListener来刷新我的位置并获得新的纬度和经度.现在我希望用户正在使用的路线将显示为红线.因此,每次调用LocationListener类的OnLocationChange()时,我都想用最后一个位置和新位置之间的一行更新地图.
到目前为止,我添加了以下内容:
private void initializeDraw() {
lineOptions = new PolylineOptions().width(5).color(Color.RED);
lineRoute = workoutMap.addPolyline(lineOptions);
}
Run Code Online (Sandbox Code Playgroud)
在OnLocationChanged期间我称之为:
drawTrail();
Run Code Online (Sandbox Code Playgroud)
现在应该插入到这个函数中,以便每次将新获得的位置作为一个点添加并从最后一个点到新点绘制一条线.
谢谢