我正在尝试使用我创建的函数直接将位图保存到文件和特定文件.它不起作用.它在bitmap.compress部分之后崩溃(在here3之前).
File dir = new File(filepath);
if(!dir.exists())dir.mkdirs();
File file = new File(Environment.getExternalStorageDirectory() + filepath, side + ".png");
FileOutputStream fOut = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.PNG, 85, fOut);
fOut.flush();
fOut.close();
System.out.println(filepath);
bitmap.recycle();
System.gc();
Run Code Online (Sandbox Code Playgroud)
错误日志:
06-29 00:16:38.089: D/AndroidRuntime(3260): Shutting down VM
06-29 00:16:38.089: W/dalvikvm(3260): threadid=1: thread exiting with uncaught exception (group=0xb587f4f0)
06-29 00:16:38.089: E/AndroidRuntime(3260): FATAL EXCEPTION: main
06-29 00:16:38.089: E/AndroidRuntime(3260): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { act=android.intent.action.VIEW dat=content://org.openintents.filemanager/mimetype//mnt/sdcard/download/02977_awreckedboatintheocean_1280x1024.jpg }} to activity {com.polygonattraction.testbirds/com.polygonattraction.testbirds.functions.SelectImageSource}: java.lang.IllegalStateException: Can't compress a recycled bitmap
06-29 00:16:38.089: E/AndroidRuntime(3260): …
Run Code Online (Sandbox Code Playgroud) 我目前正在学习Objective-C,需要知道如何编写方法描述.在Objective-C中学习如何做到这一点我遇到了很多困难.
在Jave,我们有这个
/**
< h2 >MethodName</ h2 >
< p >Various Description, can use html with images etc.</ p >
*/
private void methodName(args[]..)
{
}
Run Code Online (Sandbox Code Playgroud)
在objective-c中,我在哪里放置描述?这也是在头文件或实现文件中?
//Within Implementation?
- (float)gteHeightPercentage:(float)percentageToGet
{
return self.view.bounds.size.height * percentageToGet;
}
//Within Header?
- (float)getWidthPercentage:(float)percentageToGet;
Run Code Online (Sandbox Code Playgroud) 02-12 18:48:57.049: E/InputQueue-JNI(4659): channel '2be9da40 com.forwardapps.liveItems.LiveItemsService (client)' ~ Publisher closed input channel or an error occurred. events=0x8
Ice Cream Sandwidth(ICS)
每当我将livewallpaper设置为背景时,我都会收到此错误.它适用于所有其他版本的android.
有谁知道这里发生了什么,或者他们可以解释一下吗?
我刚刚更新了eclipse和Android SDK(12/07/2012欧洲版)并且它确实是错误的,我必须不断"清理项目"以摆脱简单的错误,例如:
Syntax error, insert ";" to complete Statement
Run Code Online (Sandbox Code Playgroud)
尽管显然有一个结局.
有其他人有这个问题,知道任何修复?
谢谢
几个月前,我的一个团队成员选择了这个可怕的应用捆绑计划。
2周前,我们发生了重大事件,AAB文件使应用程序崩溃,而经过测试的APK文件没有崩溃。在发现额外的步骤bundletool.jar之前,我们无法进行测试,这是一个噩梦。
我的问题是,一旦我们不小心选择加入该系统,该如何退出?我们只希望使用简单的APK。
我已经检查了互联网连接,并且Google Play市场安装了最新的软件包版本.
基本上,Parable失败了,因为应用内购买的buyIntent在第一次使用后返回null.
这是代码,我怀疑这个块中的错误(没有其他地方)
我也是从catch块返回的,但我不确定它是什么意思,包名称已更改,因为我不想显示我的应用程序.
错误:(不是来自我的包,而是系统级别)
[79] InAppBillingUtils.getPreferredAccount: com.mypackage.appname: Account from first account - [jbC6uT04zd8tXCrK]
Run Code Online (Sandbox Code Playgroud)
码:
Bundle buyIntentBundle = null;
try
{
buyIntentBundle =
mServiceConnection.mBillingService.getBuyIntent(
3,
mContext.getPackageName(),
mPurchaseCodesAsStrings[PurchaseType],
"inapp",
mDeveloperPayload
);
}
catch (RemoteException e)
{
e.printStackTrace();
}
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
Run Code Online (Sandbox Code Playgroud) (我使用String作为示例,但它可以替换为Object> MB的内存)
做了很多这样的事情:
private static String mTempString = "";
private static void SomeMethod()
{
mTempString = "Whatever Result";
}
Run Code Online (Sandbox Code Playgroud)
现在我的问题是,如果我是这样写的:
private static void SomeMethod()
{
String mTempString = "Whatever Result";
}
Run Code Online (Sandbox Code Playgroud)
并在循环中使用它(每秒执行数百次)作为示例,Java会知道如何管理内存吗?记忆会有效地存在.(对不起,我现在不能自己测试一下)
哪个内存效率更高(忽略它们是小变量的事实)
--edit ---在这里找到一篇很好的文章解释它http://www.cs.berkeley.edu/~jrs/4/lec/08
我使用屏幕高度百分比动态生成我的字体并设置百分比(显然将来乘以密度).
一些笔记.我正在读OTF文件.使用最新版本的LibGDX(版本1.2.0)
我有以下问题:(在字体大断裂,看上去很模糊,但仅限于媒体.大和小的外观非常尖锐)
我的预设字体大小:
//Font sizes, small, med, large as a percentage of the screen.
public static float
FONT_SIZE_LARGE = 0.175f,
FONT_SIZE_MEDIUM = 0.06f,
FONT_SIZE_SMALL = 0.04f;
Run Code Online (Sandbox Code Playgroud)
我的字体生成器设置
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
FreeTypeFontGenerator generator;
this.generator = new FreeTypeFontGenerator(Gdx.files.internal(filename));
Run Code Online (Sandbox Code Playgroud)
创建实际字体:
//Create a new font and add it to available font sizes.
public BitmapFont createFont(float size, float color)
{
this.parameter.size = Math.round(size);
BitmapFont bitmapFont = generator.generateFont(parameter);
bitmapFont.setColor(color);
listOfFonts.add(new FontStorage(bitmapFont, size));
return bitmapFont;
}
Run Code Online (Sandbox Code Playgroud)
现在我在不同的设备上尝试了一些东西,但仍然有同样的问题.我想它可能是因为它不是2的力量?(字体需要是2的幂才能均匀吗?)
字体是在许多不同的屏幕分辨率上绘制的,因此制作一定大小的三种位图字体是不可能的. …
我需要根据用户触摸事件使用可调整大小的矩形裁剪图片.我这样做是因为所有设备都不支持裁剪意图功能,所以我正在创建自己的.
我将原始图像作为位图,它作为图像视图显示在屏幕上.
现在我需要做的是有一个矩形(已经知道它需要的大小),可以调整大小并移动以供用户裁剪图像(Say get a face).
如何创建这样的可调整大小的矩形?
致电A:
double Value = Object.Object.Object.Object.DoubleValue;
Run Code Online (Sandbox Code Playgroud)
致电B:
double Value : Object.DoubleValue;
Run Code Online (Sandbox Code Playgroud)
如果这是一个for循环并且被反复调用多次会导致在对象内调用对象时出现性能损失,还是值得注意?
android ×7
java ×4
bitmap ×2
android-file ×1
comments ×1
crash ×1
crop ×1
eclipse ×1
file-io ×1
freetype ×1
libgdx ×1
objective-c ×1
opengl-es ×1
performance ×1
xcode ×1