小编App*_*evo的帖子

应用内订阅 - 应用程序的库存查询是否有限制?

我的应用程序每天可以发送的库存查询是否有限制?(通过调用 mHelper.queryInventoryAsync(mGotInventoryListener) )

\n\n

我想知道是否可以在每次应用程序启动时检查用户是否仍然拥有有效的订阅?或者也许我应该为更少的请求实现逻辑?

\n\n

我知道,由于应用内结算 v3 数据由 Google Play 服务本地缓存:\n http://developer.android.com/training/in-app-billing/purchase-iab-products.html#QueryPurchases

\n\n
\n

成功购买后,用户\xe2\x80\x99s 购买数据将由 Google Play\xe2\x80\x99s 应用内结算服务在本地\n 缓存。最好\n 经常查询应用内结算服务以了解用户\xe2\x80\x99s 的购买情况,\n 例如,每当应用程序启动或恢复时\n,以便用户\xe2\x80\x99s\n当前的应用内产品所有权信息始终反映在您的应用中。\n

\n
\n\n

但另一方面,通过 Google Play Android Developer API(配额)有 200k 请求限制:\n http://developer.android.com/google/play/billing/gp-purchase-status-api.html#using

\n\n

编辑:\n我不使用任何后端服务器。

\n

android subscriptions in-app-purchase in-app-billing

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

如果没有可用的翻译,则禁用 RTL

我有应用程序中的阿拉伯语翻译。该应用程序还支持 RTL 布局。当用户使用阿拉伯语时,一切看起来都很好。问题是,当我将 local 更改为 eq Persian(他们使用 RTL)但我不提供这种语言的翻译时,我的布局看起来一团糟。

如果当前本地没有可用的翻译,如何禁用 RTL?

android android-layout right-to-left

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

MVP - Presenter 比较:构造函数中注入的视图与 takeView(View v) / dropView()

我见过 Android 中 MVP 模式的两种方法。两者都在Android 架构蓝图中使用:

public interface Contract {
    interface View {
        void showData(String data);
    }

    interface StartVersionPresenter {
        void start();
    }

    interface DropViewVersionPresenter {
        void takeView(View view);
        void dropView();
    }
}
Run Code Online (Sandbox Code Playgroud)

1)通过构造函数注入视图的演示者:

public class StartVersionPresenter implements Contract.StartVersionPresenter {

    private final Contract.View view;
    private final Repository repository;

    public StartVersionPresenter(Contract.View view, Repository repository) {
        this.view = view;
        this.repository = repository;
    }

    @Override
    public void start() {
        loadData();
    }

    private void loadData() {
        repository.getData(new DataCallback() {
            @Override
            public …
Run Code Online (Sandbox Code Playgroud)

java mvp android dependency-injection android-mvp

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

LiveData、Transformations.map() - 当用户更改过滤顺序时如何强制刷新?

我用LiveData+ Transformations.map()

private final LiveData<List<Task>> observableTasks;
(...)
observableTasks =  Transformations.map(tasksRepository.getTasks(), tasks-> filterTasks(tasks));
Run Code Online (Sandbox Code Playgroud)

如何强制LiveData刷新?我需要Transformations.map()准备新的清单。当用户更改过滤选项时,我需要filterTasks(tasks)再次调用并显示新的排序列表。来自存储库 ( tasksRepository.getTasks()) 的数据保持不变。

java android android-livedata android-architecture-components

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

如何在库模块的代码中获取主 applicationId?

我有一个库模块,我想在其中通过 Intent(String) 来 starService。当我设置:

Intent intent1 = new Intent(BuildConfig.APPLICATION_ID + ".REFRESH_DATA");
Run Code Online (Sandbox Code Playgroud)

我的 BuildConfig.APPLICATION_ID 是一个库包。我的代码中需要一个变量,它将填充主应用程序包。

android gradle

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

具有AppCompat用法的TextView样式的父样式

如果我想设置全局textViewStyle并保持与AppCompat的向后兼容性,我应该使用哪种父样式?我找不到像Widget.AppCompat.TextView这样的东西:

<style name="Base_AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="android:textViewStyle">@style/GlobalTextViewStyle</item>

</style>

<style name="GlobalTextViewStyle" parent="?????">
    <item name="android:textAppearance">@style/TextAppearance.AppCompat.Medium</item>
</style>
Run Code Online (Sandbox Code Playgroud)

android textview android-appcompat android-support-library android-styles

4
推荐指数
2
解决办法
3885
查看次数

Spring Security - antMatcher 的 POST 方法(不是 antMatchers)

我有两个配置:

@订单(1)

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.antMatcher("/api/**")
        .authorizeRequests()
        .anyRequest().hasRole("USER")
        .and()
        .httpBasic()
        .and()
        .csrf().disable()
        .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
        .and()
        .exceptionHandling()
        .authenticationEntryPoint(new ApiAuthenticationEntryPoint(objectMapper));
}
Run Code Online (Sandbox Code Playgroud)

@订单(2)

http.authorizeRequests()
    .antMatchers("/product/**").hasRole(SecurityRoles.USER)
    .and()
    .formLogin()
    .loginPage("/login")
    .loginProcessingUrl("/authenticateTheUser")
    .successHandler(customAuthenticationSuccessHandler)
    .permitAll()
    .and()
    .logout()
    .permitAll()
    .and()
    .exceptionHandling()
    .accessDeniedPage("/access-denied");
Run Code Online (Sandbox Code Playgroud)

我需要添加功能以/api/users在没有身份验证的情况下向 REST 端点注册新用户。其他/api/**端点应保持基本身份验证。这该怎么做?我看不到antMatcher带有选择 http 方法类型选项的方法。

编辑:

我需要这样的东西:

http.antMatcher("/api/users", HttpMethod.POST.toString).permitAll()
    .and()
    .antMatcher("/api/**")
            .authorizeRequests()
            .anyRequest().hasRole("USER")
(...)
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-boot spring-config

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

用于库的Android Studio consumerProguardFiles不起作用

我想在我的库上使用proguard,但文件(规则)应该在库中设置.这意味着我不想在我的app模块中明确设置规则w(属于库).

我发现有类似consumerProguardFiles的属性.我的设置:

库gradle:

buildTypes {
    debug {
        debuggable true
        minifyEnabled false
    }
    release {
        minifyEnabled true
        consumerProguardFiles 'proguard-rules.pro'
    }
}
Run Code Online (Sandbox Code Playgroud)

app gradle:

buildTypes {
    debug {
        applicationIdSuffix ".debug"
        debuggable true
        minifyEnabled false
        signingConfig signingConfigs.debug
    }
    release {
        debuggable false
        minifyEnabled true
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么上面的配置不起作用?我收到错误,无法找到库中的包/符号.


编辑:

重要的是我的proguard-rules.pro用于库和proguard-rules.pro用于主应用程序模块都是空的.

示例错误:

Error:(3, 60) error: package (my library package here) does not exist
(...)
Error:(16, 9) error: cannot find symbol class NavigationStructureModel
(...)
Run Code Online (Sandbox Code Playgroud)

超过一个handrued错误.我可以看到我的库中的所有课程都丢失了.

android proguard android-library android-studio android-proguard

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

Android Espresso - 检查 RecyclerView 中是否不存在文本

我有检查带有文本“产品”的行是否存在于RecyclerView以下代码中:

onView(withId(R.id.rv_list)).perform(scrollTo(hasDescendant(withText("Product"))));
onView(withItemText("Product")).check(matches(isDisplayed()));

public static Matcher<View> withItemText(final String itemText) {
    checkArgument(!TextUtils.isEmpty(itemText), "itemText cannot be null or empty");
    return new TypeSafeMatcher<View>() {
        @Override
        public boolean matchesSafely(View item) {
            return allOf(
                    isDescendantOfA(isAssignableFrom(RecyclerView.class)),
                    withText(itemText)).matches(item);
        }
        @Override
        public void describeTo(Description description) {
            description.appendText("is isDescendantOfA RV with text " + itemText);
        }
    };
}
Run Code Online (Sandbox Code Playgroud)

如何检查所有列表中是否没有包含提供文本的行RecylerView

android android-espresso android-recyclerview

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

如果之前没有调用过 onResume(),是否有可能调用 onPause()?

onResume()onPause()方法中注册接收器并取消注册它。我的 Crashlytics 报告中可能出现奇怪的错误:

Fatal Exception: java.lang.RuntimeException
Unable to pause activity {package-here}: java.lang.IllegalArgumentException: Receiver not registered: 

Caused by java.lang.IllegalArgumentException
Receiver not registered:
Run Code Online (Sandbox Code Playgroud)

它在 20k 安装中发生了 3 次(3 个用户)。

如果之前没有调用过 onResume(),是否有可能调用 onPause()?我以为不是。

android illegalargumentexception receiver activity-lifecycle android-lifecycle

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