小编Mat*_*att的帖子

Espresso和postDelayed

我有一个使用postDelayed调用的活动:

public class SplashActivity extends Activity {
    private Handler handler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(...);
        handler.postDelayed(new Runnable() { 
            public void run() { finish(); }
        }, 3000L);
    }
 }
Run Code Online (Sandbox Code Playgroud)

这在app启动时运行,我需要导航它和我的登录屏幕.但是,UIController的loopMainThreadUntilIdle似乎并未将处理程序中的基础MessageQueue考虑在内.因此,当队列中仍有消息时,此操作立即结束.

onView(withId(R.id.splash_screen)).perform(new ViewAction() {
    @Override
    public Matcher<View> getConstraints() {
        return isAssignableFrom(View.class);
    }

    @Override
    public String getDescription() {
        return "";
    }

    @Override
    public void perform(final UiController uiController, final View view) {
        uiController.loopMainThreadUntilIdle();
    }
});
Run Code Online (Sandbox Code Playgroud)

在队列耗尽之前,我一直无法弄清楚如何阻止.Android本身阻止我做很多我想尝试的事情(比如扩展Handler并覆盖postDelayed方法等等)

任何人对如何处理postDelayed有任何建议?

我宁愿避免使用uiController.loopMainThreadForAtLeast,这看起来很hacky(就像Thread.sleep一样)

android android-espresso

11
推荐指数
1
解决办法
2629
查看次数

Android Wear:在Handheld上启动服务

我正在构建一个Wear应用程序,它将与掌上电脑上的WearableListenerService进行通信.但是,我想确保当应用程序在手表上启动时服务已启动并正在运行.

我最初的想法是发送意图或广播消息以启动服务.但是,我一直无法弄清楚如何让手表将其发送到配对的手持设备.

在手表方面:

Intent intent = new Intent();
intent.setAction("my.wearable.CONNECT");
sendBroadcast(intent);
Run Code Online (Sandbox Code Playgroud)

在手持设备方面:

public class WearableBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Intent startServiceIntent = new Intent(context, WearableService.class);
        context.startService(startServiceIntent);
    }
}

<receiver android:name=".service.wearable.WearableBroadcastReceiver" >
    <intent-filter>
        <action android:name="my.wearable.CONNECT" />
    </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)

android wear-os

8
推荐指数
1
解决办法
1942
查看次数

级联保存不适用于 Hibernate 4 和 @OneToMany

我在 Hibernate 4 中遇到了一个在 Hibernate 3 中没有发生的问题。我正在测试一个基本的 dao 类,它具有用于保存、查询等的通用方法......(不是它不是作业)。我正在使用带有 hibernate.hbm2ddl.auto=create-drop 的嵌入式 derby 连接进行测试。

编辑:修复级联类型。还是一样的行为。即使我从 CascadeType 枚举中添加了所有可用的级联类型,它仍然会失败,除非我放入 CascadeType.ALL。不确定 ALL 有哪些您无法具体列举的内容。

在我的测试中,我有以下映射类:

@Entity
@Table(name="FOO_CHILD")
public class FooChild {
    @Id
    @Column(name="FOO_ID")
    private Long id;

    @Column(name="NAME")
    private String name;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

@Entity
@Table(name="FOO_PARENT")
public class FooParent {
    @Id
    @Column(name="FOO_PARENT_ID")
    private Long id;

    @Column(name="NAME") …
Run Code Online (Sandbox Code Playgroud)

java dao hibernate jpa

6
推荐指数
1
解决办法
8153
查看次数

Firebase iOS / Swift 和深层链接

我们刚刚集成了 firebase,突然间我们的深层链接不再有效。我们使用 AppAuth 进行身份验证,因此我们依赖深层链接将我们引导到正确的位置。我收到以下错误:

<Debug> [Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {...}
Run Code Online (Sandbox Code Playgroud)

firebase的初始化如下:

let bundleId = Bundle.main.bundleIdentifier
let filePath = Bundle.main.path(forResource: "GoogleService-Info-" + bundleId!, ofType: "plist")!
let options = FIROptions(contentsOfFile: filePath)
FIRApp.configure(with: options!)
Run Code Online (Sandbox Code Playgroud)

这是深层链接功能:

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
        return application(app, open: url, sourceApplication: nil, annotation: [:])
    }

    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        if url.host == AppHost.deeplink …
Run Code Online (Sandbox Code Playgroud)

ios firebase swift firebase-crash-reporting

6
推荐指数
1
解决办法
3074
查看次数