小编Gre*_*reg的帖子

如何在应用程序停止时从GCM接收通知

如果应用程序未运行,GCMIntentService(extends GCMBaseIntentService)不会收到通知.

来自:http://developer.android.com/about/versions/android-3.1.html

启动已停止应用程序的控件请注意,系统会将FL​​AG_EXCLUDE_STOPPED_PACKAGES添加到所有广播意图.这样做是为了防止来自后台服务的广播无意或不必要地启动已停止的应用程序的组件.后台服务或应用程序可以通过将FLAG_INCLUDE_STOPPED_PACKAGES标志添加到应允许激活已停止的应用程序的广播意图来覆盖此行为.

有办法解决这个问题吗?谢谢

android push-notification google-cloud-messaging

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

使用byte []取消Android Unread Field警告

java.lang.SuppressWarnings在Android Studio中使用该软件包.

我无法摆脱这一个:

EI_EXPOSE_REP2: May expose internal representation by incorporating reference to mutable object (findbugs task)
Run Code Online (Sandbox Code Playgroud)

它发生在setter方法中.

如何摆脱这种警告?

 public class PropertyDetailDocumentStorageModel implements Parcelable {
 @SerializedName("picture")
 private byte[] mPicture;    
 public void setmPicture(byte[] mPicture) { this.mPicture = mPicture; }
Run Code Online (Sandbox Code Playgroud)

警告:

setmPicture(byte[]) may expose internal representation by storing an externally mutable object into PropertyDetailDocumentStorageModel.mPicture
Run Code Online (Sandbox Code Playgroud)

请注意,这是在类型为唯一的字段上发生的byte[].同一类中具有getter的其他字段不会抛出此警告.

java arrays android findbugs

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

为什么 KeyPairGeneratorSpec 在 API < 24 上抛出 InvalidAlgorithmParameterException

当我在 API 24 中使用此 KeyPairGeneratorSpec 对象时,我的类可以正常工作。

KeyPairGeneratorSpec spec = new KeyPairGeneratorSpec.Builder(this)
                    .setAlias(KEY_ALIAS)
                    .setSubject(new X500Principal("CN=" + KEY_ALIAS))
                    .setSerialNumber(BigInteger.TEN)
                    .setStartDate(start.getTime())
                    .setEndDate(end.getTime())
                    .build();
            KeyPairGenerator kpg = KeyPairGenerator.getInstance(RSA);
            kpg.initialize(spec);
            keyPair = kpg.generateKeyPair();
Run Code Online (Sandbox Code Playgroud)

在低于 24 的版本上编译时,出现以下错误:

java.security.InvalidAlgorithmParameterException: Only RSAKeyGenParameterSpec supported
Run Code Online (Sandbox Code Playgroud)

我不明白,因为 KeyPairGeneratorSpec 应该可以从 api 18 获得?

android key-pair android-keystore

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