小编Ant*_*ton的帖子

MediaStore.Images.Media.getBitmap和内存不足错误

我的代码是:

public Bitmap loadPhoto(Uri uri) {
    Bitmap scaled = null;
    try {
    scalled = Bitmap.createBitmap(
      MediaStore.Images.Media.getBitmap(getContentResolver(), uri),
      0,0,90, 90);

    if (scaled == null) { return null; }
    } catch(Exception e) { }
    return scaled;
}
Run Code Online (Sandbox Code Playgroud)

在这之后.我在ImageView中显示缩放.每张图片都来自设备相机.

每次,我都会收到错误:我从相机显示三张照片后内存不足.怎么解决这个?

android bitmap out-of-memory imageview

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

Java Regex问题\ b

\b在Java Regexp中尝试过(这意味着一个单词的最后一个字符),但这不起作用.

String input = "aaa aaa";
Pattern pattern = Pattern.compile("(a\b)");
Matcher matcher = pattern.matcher(input);

while (matcher.find()) {
    System.out.println("Found this wiki word: " + matcher.group());
}
Run Code Online (Sandbox Code Playgroud)

有什么问题?

java regex

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

AnimationDrawable在Android 2.2中不起作用

我像这样使用AnimationDrawable:

ImageView rocketImage = (ImageView) layout.findViewById(R.id.animation);
rocketImage.setBackgroundResource(R.drawable.progress_blue_animation);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketAnimation.start();
Run Code Online (Sandbox Code Playgroud)

此代码适用于Android 3.0/4.0/4.1/4.0,但在Android 2.2中不起作用.如何解决这个问题呢?

android drawable android-animation

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