livewallpaper力量关闭集

时间:2013-12-05 15:04:52

标签: java android live wallpaper

我可以获得有关在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

1 个答案:

答案 0 :(得分:1)

查看错误“1085506396字节分配时内存不足”。可能由于设备内存不足或壁纸尺寸过大而导致此错误。

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