小编Евг*_*цов的帖子

Google 拒绝对隐式 PendingIntent 漏洞进行补救更新

当我尝试更新我的应用程序时 - 在审核过程中出现错误。隐式 PendingIntent 漏洞的修复 - https://support.google.com/faqs/answer/10437428。在我的应用程序中,我正在创建 PendingIntent - 用于 Firebase 推送通知:

内部类 FCMService 扩展了 FirebaseMessagingService

@Override
    public void onMessageReceived(@NotNull RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);

        Intent intent = new Intent(this, ApplicationActivity.class);
        intent.setAction("com.google.firebase.MESSAGING_EVENT");
        intent.setPackage(getApplicationContext().getPackageName());

        Map<String, String> data = remoteMessage.getData();
        for (Map.Entry<String, String> entry : data.entrySet()) {
            String value = entry.getValue();
            String key = entry.getKey();
            if (key.equals(ApplicationActivity.LINK_URL) ||
                    key.equals(ApplicationActivity.FLOCKTORY_LINK_URL)) {
                intent.putExtra(ApplicationActivity.FLOCKTORY_LINK_URL, value);
                if (remoteMessage.getNotification() != null && remoteMessage.getNotification().getTitle() != null) {
                    intent.putExtra(ApplicationActivity.HMS_PUSH_TITLE, remoteMessage.getNotification().getTitle());
                }
            }
        }

        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, …
Run Code Online (Sandbox Code Playgroud)

java android google-play huawei-mobile-services huawei-push-notification

26
推荐指数
2
解决办法
1594
查看次数

在Rx链中多次切换线程

我们假设我有以下Android案例:

  1. 请求来自网络的组列表
  2. 显示每个组的一些UI元素
  3. 请求每个组的项目
  4. 显示每个项目的UI元素

我想用RxJava做到这一点:

webService.requestGroups()
        .flatMap(group -> {
            view.showGroup(group);
            return webService.requestItems(group);
        })
        .toList()
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())

        .subscribe(items -> view.showItems(items));
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我有2个视图对象调用,每个调用都必须在主线程上执行.并且2次调用webService,必须在后台线程上执行.

这段代码的问题:首先调用view会在后台执行导致Android RuntimeException(只有原始线程可能会触及视图或者其他东西)如果我转移.observeOn到链的开头 - 第二次webService调用将在主线程中执行.

如何在RxJava链中多次"游"穿过线程?

android rx-java rx-java2

8
推荐指数
2
解决办法
3340
查看次数

水平RecyclerView具有可变项目高度

我在ConstraintLayout中有一个水平方向的RecyclerView作为它的直接子节点.Recycler匹配父母的widht,并根据项目的视图高度设置其高度.问题 - Recycler无法根据项目的视图高度增加或减少其高度.

例如,屏幕开始处的3个可见项目具有类似的100dp高度.接下来,我滚动 - 并看到200 dp高度项目.它将部分冷杉100dp窗口,用户将看不到所有内容.

有没有人面对这个问题?

android android-recyclerview

7
推荐指数
1
解决办法
373
查看次数

Swift套接字无效的HTTP升级

美好的一天,

我在localhost:80上建立了非常简单的Python服务器(Twisted框架).它可以正常使用telnet - 我可以发送和接收简单的消息.但我需要将Swift iOS app客户端连接到此服务器.应用程序在模拟器上运行

我正在使用Socket_IO_Client_Swift框架.此时,我刚刚创建了带有"localhost:80"参数的套接字对象,并在应用程序启动时调用了connect()方法.

服务器可以看到来自客户端的信号,但客户端在连接此消息后会立即断开连接:

得到事件:断开连接,带有项目:可选(("无效的HTTP升级")

我该怎么做才能解决这个问题,什么是HTTP升级?

谢谢

swift

5
推荐指数
0
解决办法
1343
查看次数

Volley忽略Cookie标头请求

美好的一天!

我的应用程序使用简单的http客户端 - 服务器通信,在客户端与Volley库建立.首先,我启动一个授权请求:

public class AuthenticationRequest extends StringRequest {

    private static final String TAG = AuthenticationRequest.class.getSimpleName();

    private String login;
    private String password;

    public AuthenticationRequest(int method,
                                 String url,
                                 Response.Listener<String> listener,
                                 Response.ErrorListener errorListener) {
        super(method, url, listener, errorListener);
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    protected Map<String, String> getParams() {
        HashMap<String, String> parameters = new HashMap<>();
        parameters.put("login", login);
        parameters.put("password", password);
        return parameters;
    }

    @Override
    protected Response<String> parseNetworkResponse(NetworkResponse response) …
Run Code Online (Sandbox Code Playgroud)

android androidhttpclient android-volley android-cookiemanager

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

UIActivityIndi​​catorView 忽略颜色属性

这是我初始化 UIActivityAndicatorView 的代码:

self.indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
    self.indicator.color = [UIColor colorWithRed:252.0 green:113.0 blue:9.0 alpha:1.0];
    self.indicator.center = self.view.center;
    [self.view addSubview:self.indicator];
Run Code Online (Sandbox Code Playgroud)

动画开始后 - 指示器出现在适当的位置,但为白色。为什么忽略颜色属性?

ios

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

Mockito anyBoolean() 返回时匹配器异常

尝试用 Mockito 编写一个简单的单元测试:

@Test
    public void toggleBlockingControlTest_turnOff() {
        when(mainViewPresenter.getAppSettingsStorage().loadBlockingStatus())
                .thenReturn(Mockito.anyBoolean());

        AppSettingsStorage appSettingsStorage = mainViewPresenter.getAppSettingsStorage();
        boolean statusBefore = appSettingsStorage.loadBlockingStatus();

        Mockito.verify(appSettingsStorage).saveBlockingStatus(Mockito.eq(!statusBefore));
    }
Run Code Online (Sandbox Code Playgroud)

在运行时我得到 org.mockito.exceptions.misusing.InvalidUseOfMatchersException: 在这个字符串:

.thenReturn(Mockito.anyBoolean());
Run Code Online (Sandbox Code Playgroud)

我是 Mockito 的新手,不明白为什么这个框架不能返回任何布尔值???

java junit android mockito

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

单元测试私有字段

我有一个简单的类,其中包含一个列表:

public class SomeClass {

    private AppDataSource appDataSource; // it's interface
    private List<Object> someList;

    ////

    public List<Obejct> loadSomeList() {
        if (someList == null) {
            return appDataSource.getListFromDatabase();
        }
        retrunf someList;
    }
}
Run Code Online (Sandbox Code Playgroud)

关键是 - 我希望该列表仅从DB加载一次.我想对这个功能进行单元测试.我是TDD中的noob,我能做的就是 - 为someList编写一个公共getter和setter,并在单元测试中使用它们.但它在概念上是错误的 - 我不希望类的客户端使用此成员变量directlty.

在这种情况下如何正确测试方法?

java tdd junit unit-testing

0
推荐指数
1
解决办法
3331
查看次数