Malfunctioning in Lollipop but Functioning in KitKat

142 views Asked by At

I'm trying to give an EndGame response to players based on their performance on a game.

I access the method "onDraw" from MainActivity to display the message.

It works like a charm in Kitkat but on lollipop it somehow crashes.

Here are the codes:

In MainActivity

if (rec.getGameOver()) {
            saveScore(rec.getScore());
            rec.onDraw(rec.getCanvas());
        }

In Game class extends view

 if (score > value) {
            paint.setColor(Color.parseColor("#000000"));
            paint.setTextSize((int) (value));
            canvas1.drawText("Nice!", 0, (int) (value), paint);
            canvas1.drawText("Your got" + score, 0, (int) (value), paint);
        } else {
            paint.setColor(Color.parseColor("#000000"));
            paint.setTextSize((int) (value);
            canvas1.drawText("Try Again?!", 0, (int) (value), paint);
            canvas1.drawText("Your got" + score, 0, (int) (value), paint);
        }
        invalidate();

Every variable was already defined before use.

edit: here is the error

06-20 16:14:51.656 1232-26777/? W/ActivityManager﹕ Exception thrown during pause android.os.DeadObjectException at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:496) at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:704) at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:825) at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2726) at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2583) at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2497) at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:11500) at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:11397) at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:12081) at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:11592) at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)

0

There are 0 answers