- 浏览: 21445 次
- 性别:
- 来自: 成都
最新评论
文章列表
对library project的混淆需要在主工程的混淆配置文件中设置
参考:https://stackoverflow.com/questions/10982344/is-proguard-cfg-needed-for-library-projects#10992604
https://stackoverflow.com/questions/8088958/how-to-obfuscate-an-android-library-jar-file-using-proguard-in-eclipse
https://www.guardsquare.com/en/proguard/manual/in ...
自定义 Indeterminate ProgressBar:
先定义一个ring shape
custom_progress_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="4000"
android:fromDegrees="0"
a ...
最近实现了一个自定义Notification功能,使用RemoteViews展示。由于该notification是个ongoing的类型,更新比较频繁,于是想当然的把RemoteViews缓存起来,每次重更新文本,图片。 功能一直正常,直到后来碰上TransactionTooLargeException,应用crash。分析代码发现不应该出现notification parcel size过大的情况。开始怀疑加载的图片过大, 但是这里使用的是RemoteViews,不会把图片内容直接传递。为了确认这个情况,最后发现,原来RemoteViews那一堆堆setXXX的方法,最后都是构造一个Actio ...
定义theme和style, 注意是actionOverflowMenuStyle 和 android:windowBackground.(实测5.1.1和7.1.1)
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionOverflowMenuStyle">@style/CustomActionOverflowMenuStyle</item>
<item name=&q ...
直接代码示例:
import com.google.common.base.Splitter;
import org.ethereum.crypto.jce.SpongyCastleProvider;
import org.spongycastle.asn1.ASN1ObjectIdentifier;
import org.spongycastle.asn1.pkcs.PKCSObjectIdentifiers;
import org.spongycastle.asn1.pkcs.PrivateKeyInfo;
import org.spongycastle.asn1.x509.*; ...
可用辅助方法:
public static boolean isInBackground(Context context) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses();
boolean isInBackgro ...
手机启动后,后台broadcast满天飞。可能点击自己应用的Notification 启动的broadcast半天不响应。这时候加上FLAG_RECEIVER_FOREGROUND吧。注意此flag在API 16中引入.
示例:
Intent intent = new Intent(context, XXXReceiver.class);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
intent.addFlags(Intent.FL ...
设备M或者M以上,当用户手动在系统设置中disable掉应用任何runtime permission时,运行的应用process会被kill掉,重回前台的时候,系统会恢复应用的task。但是这里需要注意Activity恢复的相关处理:
1. 如果你的页面是通过onSaveInstanceState和onRestoreInstanceState记录状态并恢复的。那么恭喜你,你不需要做额外的工作。
2. 如果你是基于onRetainNonConfigurationInstance和getLastNonConfigurationInstance的,那么你有事了。重新恢复时getLastNonConfi ...
Issue: https://code.google.com/p/android/issues/detail?id=169768
问题摘要:
===============================================================
1)The app starts with Activity A, which simply shows a button called "Launch B". 2)Press this button -- this executes startActivity(FLAG_ACTIVITY_REORDER_T ...
Issue: https://code.google.com/p/android/issues/detail?id=59310
android.text.TextLine has memory leak on mSpanned and SpanSet.
使用下面的工具类移除泄漏:
public class TextLineRecycler {
private static Field sCached;
private static Field sCharacterStyleSpanSet;
private static Field sMetricAffectin ...
If app is in standby state, network access is unavailable.
The system will release app from the standby state if it shows a toast.
所以当你处于standby,又想使用网络的情况,简单的先show一个toast。
由于Android M上的doze mode,AlarmManager#setExact等并不能保证按时执行alarm。可用AlarmManager#setAlarmClock。
Android N does not support "Crypto" provider any more.
Solution:
Switch to use SecretKeySpec to load raw key bytes directly for N if want to decrypt old info.
The raw key bytes can be got by previous platform.
1. MyLinkify extends Linkify, add custom sub class of URLSpan to addLinks. Use MyLinkify to apply span to string or textview.
2. If textview is linkable, get all URLSpan from the Spannable text. Use the URLSpan to construct you custom ClickableSpan.
example:
TextView tv =(TextView)this.findViewById( ...
1.SpannableStringBuilder
example:
String str = "highlight me!";
String highLight = "me";
int start = str.indexOf(highLight);
SpannableStringBuilder style=new SpannableStringBuilder(str);
style.setSpan(new BackgroundColorSpan(Color.RED), start, start + highLight.length(),Spanna ...