gpt4 book ai didi

java - 动态壁纸强制接近场景

转载 作者:行者123 更新时间:2023-12-01 13:45:25 25 4
gpt4 key购买 nike

我可以获得关于我在 Eclipse 中制作的动态壁纸的帮助吗,我收到几个 logcat 错误。我已经研究了几个小时,不知道为什么我总是强制关闭。我在“动态壁纸选择屏幕”上强制关闭。当我运行该应用程序时,我什至无法查看任何动态壁纸。 int x,y;

            public void onCreate()
{
super.onCreate();
}

public void onDestroy()
{
super.onDestroy();
}

public Engine onCreateEngine()
{
return new MyWallpaperEngine();
}

class MyWallpaperEngine extends Engine
{

private final Handler handler = new Handler();
private final Runnable drawRunner = new Runnable() {
@Override
public void run() {
draw();
}
};
private boolean visible = true;
public Bitmap image1,backgroundImage;

MyWallpaperEngine()
{
// get the fish and background image references
image1 = BitmapFactory.decodeResource(getResources(),R.drawable.fish);
backgroundImage = BitmapFactory.decodeResource(getResources(),R.drawable.water);
x=-130; // initialize x position
y=200; // initialize y position

}


public void onCreate(SurfaceHolder surfaceHolder)
{
super.onCreate(surfaceHolder);
}

@Override
public void onVisibilityChanged(boolean visible)
{
this.visible = visible;
if (visible)
{
handler.post(drawRunner);
}
else
{
handler.removeCallbacks(drawRunner);
}
}

@Override
public void onSurfaceDestroyed(SurfaceHolder holder)
{
super.onSurfaceDestroyed(holder);
this.visible = false;
handler.removeCallbacks(drawRunner);
}

public void onOffsetsChanged(float xOffset, float yOffset,
float xStep, float yStep, int xPixels, int yPixels)
{
draw();
}

void draw()
{
final SurfaceHolder holder = getSurfaceHolder();

Canvas c = null;
try
{
c = holder.lockCanvas();
// clear the canvas
c.drawColor(Color.BLACK);
if (c != null)
{
// draw the background image
c.drawBitmap(backgroundImage, 0, 0, null);
// draw the fish
c.drawBitmap(image1, x,y, null);
// get the width of canvas
int width=c.getWidth();


if(x>width+100)
{
// assign initial value to start with
x=-130;
}
// change the x position/value by 1 pixel
x=x+1;
}
}
finally
{
if (c != null)
holder.unlockCanvasAndPost(c);
}

handler.removeCallbacks(drawRunner);
if (visible)
{
handler.postDelayed(drawRunner, 10);
}

}
}

现在这是我的 Logcat

    12-05 09:29:28.893: I/ActivityManager(794): START u0 {act=android.intent.action.SET_WALLPAPER cmp=com.google.android.googlequicksearchbox/com.google.android.launcher.GelWallpaperPickerActivity} from pid 1209
12-05 09:29:28.954: I/ActivityManager(794): Start proc com.google.android.googlequicksearchbox:wallpaper_chooser for activity com.google.android.googlequicksearchbox/com.google.android.launcher.GelWallpaperPickerActivity: pid=8101 uid=10022 gids={50022, 3003, 1028, 3002, 1015}
12-05 09:29:29.054: E/MP-Decision(1580): num online cores: 1 reqd : 3 available : 4 rq_depth:3.800000 hotplug_avg_load_dw: 60
12-05 09:29:29.054: E/MP-Decision(1580): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:143.000000
12-05 09:29:29.054: E/MP-Decision(1580): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:143.000000
12-05 09:29:29.404: E/MP-Decision(1580): num online cores: 3 reqd : 2 available : 4 rq_depth:1.700000 hotplug_avg_load_dw: 112
12-05 09:29:29.404: E/MP-Decision(1580): DOWN cpu:2 core_idx:2 Ns:2.100000 Ts:240 total_time_down:245.000000
12-05 09:29:29.504: E/MP-Decision(1580): num online cores: 2 reqd : 3 available : 4 rq_depth:5.700000 hotplug_avg_load_dw: 72
12-05 09:29:29.504: E/MP-Decision(1580): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
12-05 09:29:29.504: E/MP-Decision(1580): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:92.000000
12-05 09:29:29.524: D/dalvikvm(24807): null clazz in OP_INSTANCE_OF, single-stepping
12-05 09:29:29.554: E/MP-Decision(1580): num online cores: 3 reqd : 4 available : 4 rq_depth:4.000000 hotplug_avg_load_dw: 140
12-05 09:29:29.554: E/MP-Decision(1580): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
12-05 09:29:29.554: E/MP-Decision(1580): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:0.000000
12-05 09:29:29.554: E/MP-Decision(1580): UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:138.000000
12-05 09:29:29.644: I/Adreno200-EGL(8101): <qeglDrvAPI_eglInitialize:265>: EGL 1.4 QUALCOMM Build: Iabe52cfaeae4c5fab1acacfe6f056ba15fa93274
12-05 09:29:29.744: D/OpenGLRenderer(8101): Enabling debug mode 0
12-05 09:29:29.804: E/MP-Decision(1580): num online cores: 4 reqd : 3 available : 4 rq_depth:2.000000 hotplug_avg_load_dw: 97
12-05 09:29:29.804: E/MP-Decision(1580): DOWN cpu:3 core_idx:3 Ns:3.100000 Ts:240 total_time_down:241.000000
12-05 09:29:30.065: I/ActivityManager(794): Displayed com.google.android.googlequicksearchbox/com.google.android.launcher.GelWallpaperPickerActivity: +1s118ms
12-05 09:29:30.155: E/MP-Decision(1580): num online cores: 3 reqd : 4 available : 4 rq_depth:3.800000 hotplug_avg_load_dw: 115
12-05 09:29:30.155: E/MP-Decision(1580): UP cpu:1 core_idx:1 Nw:1.900000 Tw:140 total_time_up:0.000000
12-05 09:29:30.155: E/MP-Decision(1580): UP cpu:2 core_idx:2 Nw:2.700000 Tw:90 total_time_up:0.000000
12-05 09:29:30.155: E/MP-Decision(1580): UP cpu:3 core_idx:3 Nw:3.500000 Tw:90 total_time_up:98.000000
12-05 09:29:30.355: I/dalvikvm-heap(8101): Forcing collection of SoftReferences for 1085506396-byte allocation
12-05 09:29:30.375: E/dalvikvm-heap(8101): Out of memory on a 1085506396-byte allocation.
12-05 09:29:30.375: I/dalvikvm(8101): "AsyncTask #1" prio=5 tid=13 RUNNABLE
12-05 09:29:30.375: I/dalvikvm(8101): | group="main" sCount=0 dsCount=0 obj=0x423ac980 self=0x75ed44b0

最佳答案

查看错误“1085506396 字节分配内存不足”。您收到此错误的原因可能是设备内存不足或者壁纸尺寸太大。

尝试减小动态壁纸的大小或尝试使用内存较大的设备(或模拟器)。

关于java - 动态壁纸强制接近场景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20403419/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com