Reputation: 1
Could i get help with a live wallpaper ive been making in eclipse, I get several logcat errors. ive been working at it for a couple hours and dont know why i keep getting force closes. i get force closes on the "live wallpaper selection screen". i am not even able to view any live wallpapers when i run the application. 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);
}
}
}
Now Here is my 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
Upvotes: 0
Views: 167
Reputation: 46
Look at the error "Out of memory on a 1085506396-byte allocation". Maybe you are getting this error due to low device memory or maybe the wallpaper size is too large.
Try to reduce the size of the live wallpaper or try to use a device (or emulator) with larger memory size.
Upvotes: 1