小编Moh*_*ara的帖子

Android studio Emulator(未经授权的设备)

我知道在普通设备上我必须授权调试过程,但是在模拟器上授权它是我的第一次.

我刚刚在我的家用电脑上安装了我的第一个模拟器来做一些工作,这就加速了.

知道是什么原因或者对于android o api 26谷歌播放SDK是否正常?

PS:我在家里使用Windows版本.

android android-emulator android-8.0-oreo

15
推荐指数
1
解决办法
2万
查看次数

如何为api 21修复context.getSystemService(class)?

我正在关注视频JobScheduler:

https://www.youtube.com/watch?v=XFN3MrnNhZA

但是lint给了我那context.getSystemService(class)api 23.因为我错过了一些东西或者是否有机器人用api改变了什么?

注意:大多数人想知道是否JobScheduler介绍了api 21如何在没有它的情况下工作getSystemService(Class)

谢谢.

java android android-jobscheduler

6
推荐指数
2
解决办法
2867
查看次数

小部件使用约束布局

我试图为我的小部件使用constraintLayout,但它在第0行给了我一个错误(xml不是从第1行开始?).

这是代码:

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFF"
    android:padding="@dimen/widget_margin">


    <TextView
        android:id="@+id/appwidget_text"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_margin="8dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:background="#09C"
        android:text="@string/appwidget_text"
        android:textColor="#ffffff"
        android:textSize="24sp"
        android:textStyle="bold|italic"
        android:gravity="center"
        app:layout_constraintBottom_toTopOf="@+id/split2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.501"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:contentDescription="@string/appwidget_text"/>

    <Button
        android:id="@+id/flip"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginStart="8dp"
        android:text="@string/show_answer"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/split"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/split2" />

    <Button
        android:id="@+id/next"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:text="@string/next_question"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@+id/split"
        app:layout_constraintTop_toBottomOf="@+id/split2" />

    <android.support.constraint.Guideline
        android:id="@+id/split"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layout_constraintGuide_percent="0.5" />

    <android.support.constraint.Guideline
        android:id="@+id/split2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintGuide_percent="0.75" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

错误:

二进制XML文件行#0:二进制XML文件行#0:错误膨胀类android.support.constraint.ConstraintLayout

注意:我尝试使用线性布局并且它工作,但我更喜欢使用constraintLayout.

xml android android-layout android-constraintlayout

5
推荐指数
1
解决办法
2472
查看次数

旋转按钮浓缩咖啡测试点击不起作用

我正在玩浓缩咖啡,我注意到我的一个按钮无法点击。我尝试在屏幕上移动它以及使其自动单击的所有内容,但失败了。然后我注意到它有一个rotation=180. 通过删除它,问题似乎得到了解决,但这是必要的。

这是我的测试代码:

@Test
public void orderUp() throws Exception {
    onView(ViewMatchers.withId(R.id.move_up)).perform(ViewActions.click());
    onView(withText("Up")).inRoot(withDecorView(not(is(menuActivityTestRule.getActivity().getWindow().getDecorView())))).check(matches(isDisplayed()));
}
Run Code Online (Sandbox Code Playgroud)

那么,如何使测试用例适用于旋转按钮呢?

编辑:“错误日志表明我认为未找到 Toast”

android.support.test.espresso.NoMatchingRootException: Matcher 'with decor view not is <DecorView@1ec572[MainActivity]>' did not match any of the following roots: [Root{application-window-token=android.view.ViewRootImpl$W@449fd58, window-token=android.view.ViewRootImpl$W@449fd58, has-window-focus=true, layout-params-type=1, layout-params-string=WM.LayoutParams{(0,0)(fillxfill) ty=1 fl=#81810100 pfl=0x20000 wanim=0x103046c needsMenuKey=2 naviIconColor=0}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=1080, height=1920, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=WM.LayoutParams{(0,0)(fillxfill) ty=1 fl=#81810100 pfl=0x20000 wanim=0x103046c needsMenuKey=2 naviIconColor=0}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=2}}]
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1567)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:90)
at …
Run Code Online (Sandbox Code Playgroud)

android android-espresso

4
推荐指数
1
解决办法
512
查看次数