TensorFlowlite Object detection demo app activity(Android studio) won't launch - java

Trying to tweak the app by launching the DetectorActivity(main activity that does the detection) only when a button is clicked.
So within the source code, I've added a class "Main Activity", set it as the launching activity in the manifest, and in it's xml, added a button that when clicked, should send an intent to the DetectorActivity and launch it. The code is pretty much this :
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void on(View v){
Intent i = new Intent(this,DetectorActivity.class);
startActivity(i);
}
However, the activity is never launched, which is quite baffling.
Here is the logcat of the emulator:
I/art: Ignoring second debugger -- accepting and dropping
12-21 20:39:13.111 23543-23550/.abc I/art: Ignoring second debugger -- accepting and dropping
12-21 20:39:13.563 23543-23543/.abc W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
12-21 20:39:13.745 23543-23554/abc I/art: Background sticky concurrent mark sweep GC freed 9521(535KB) AllocSpace objects, 0(0B) LOS objects, 75% free, 950KB/3MB, paused 8.576ms total 187.364ms
12-21 20:39:14.110 23543-23543/abc I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
12-21 20:39:14.112 23543-23543/.abc I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>
12-21 20:39:15.082 23543-23577/abc D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-21 20:39:15.338 23543-23577/.abc I/OpenGLRenderer: Initialized EGL, version 1.4
12-21 20:39:15.338 23543-23577/abc W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
12-21 20:39:15.387 23543-23577/abc D/EGL_emulation: eglCreateContext: 0x7f758dd74f40: maj 2 min 0 rcv 2
12-21 20:39:15.403 23543-23577/abc D/EGL_emulation: eglMakeCurrent: 0x7f758dd74f40: ver 2 0 (tinfo 0x7f758dd532a0)
12-21 20:39:15.777 23543-23577/abc D/EGL_emulation: eglMakeCurrent: 0x7f758dd74f40: ver 2 0 (tinfo 0x7f758dd532a0)
12-21 20:39:16.102 23543-23543/abc I/Choreographer: Skipped 56 frames! The application may be doing too much work on its main thread.
12-21 20:57:47.896 23543-23550/abc I/art: Ignoring second debugger -- accepting and dropping
12-21 20:57:47.909 23543-23550/abc I/art: Ignoring second debugger -- accepting and dropping
12-21 21:00:48.853 23543-23550/abc I/art: Ignoring second debugger -- accepting and dropping
Any help in this matter would be truly appreciated!

How are you setting the click listener? This log suggests it's not being called.
The comment by #RyanMentley solved it, thanks a bunch.

Related

Java Android Studio Application working very slowly and laggy

The application is very laggy and the more things are being clicked, the more it lags. At some point it completely freezes. This is my error log. How can i optimize it? (Full beginner)
NativeAlloc concurrent copying GC freed 8231(560KB) AllocSpace objects, 1(20KB) LOS objects, 49% free, 5936KB/11MB, paused 44.140ms total 1.790s
I/Choreographer: Skipped 30 frames! The application may be doing too much work on its main thread.
I/OpenGLRenderer: Davey! duration=820ms; Flags=0, IntendedVsync=12357482298756, Vsync=12357982298736, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=12358003456500, AnimationStart=12358003547700, PerformTraversalsStart=12358005401700, DrawStart=12358023891800, SyncQueued=12358058644400, SyncStart=12358063300300, IssueDrawCommandsStart=12358065361800, SwapBuffers=12358274912900, FrameCompleted=12358307408500, DequeueBufferDuration=3954100, QueueBufferDuration=21280700, GpuCompleted=0,
I/ample.indistan: Thread[5,tid=11901,WaitingInMainSignalCatcherLoop,Thread*=0xdf380010,peer=0x13600268,"Signal Catcher"]: reacting to signal 3
I/ample.indistan: Mutator lock exclusive owner tid: 18446744073709551615
ThreadList lock owner tid: 11919
ClassLinker classes lock owner tid: 0
ClassLinker dex lock owner tid: 0
I/ample.indistan: Waiting for a blocking GC ObjectsAllocated
I/ample.indistan: NativeAlloc concurrent copying GC freed 4035(425KB) AllocSpace objects, 3(60KB) LOS objects, 49% free, 5972KB/11MB, paused 2.528ms total 289.491ms
I/ample.indistan: WaitForGcToComplete blocked ObjectsAllocated on ProfileSaver for 5.863ms
I/ample.indistan: Wrote stack traces to tombstoned
I/Choreographer: Skipped 205 frames! The application may be doing too much work on its main thread.
W/ample.indistan: Verification of boolean androidx.core.view.KeyEventDispatcher.actionBarOnMenuKeyEventPre28(android.app.ActionBar, android.view.KeyEvent) took 105.167ms (494.45 bytecodes/s) (1768B approximate peak alloc)
W/ample.indistan: Verification of boolean androidx.core.view.KeyEventDispatcher.activitySuperDispatchKeyEventPre28(android.app.Activity, android.view.KeyEvent) took 126.372ms (538.09 bytecodes/s) (1728B approximate peak alloc)
V/FA: Recording user engagement, ms: 63317
I/Choreographer: Skipped 322 frames! The application may be doing too much work on its main thread.
V/FA: Connecting to remote service
V/FA: onActivityCreated
V/FA: Connection attempt already in progress
V/FA: Activity paused, time: 12386204
V/FA: Activity resumed, time: 12391211
V/FA: Connection attempt already in progress
V/FA: Connection attempt already in progress
I/Choreographer: Skipped 267 frames! The application may be doing too much work on its main thread.
W/RecyclerView: No adapter attached; skipping layout
I/OpenGLRenderer: Davey! duration=5309ms; Flags=1, IntendedVsync=12387232708368, Vsync=12391682708190, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=12391699342600, AnimationStart=12391699362500, PerformTraversalsStart=12391709661200, DrawStart=12392393938500, SyncQueued=12392471934000, SyncStart=12392475519700, IssueDrawCommandsStart=12392475611700, SwapBuffers=12392518233700, FrameCompleted=12392545949800, DequeueBufferDuration=1156600, QueueBufferDuration=14934400, GpuCompleted=8223625903103697763,
I/OpenGLRenderer: Davey! duration=5411ms; Flags=1, IntendedVsync=12387232708368, Vsync=12391682708190, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=12391699342600, AnimationStart=12391699362500, PerformTraversalsStart=12391709661200, DrawStart=12392632905600, SyncQueued=12392639112300, SyncStart=12392640203300, IssueDrawCommandsStart=12392641107800, SwapBuffers=12392643554700, FrameCompleted=12392645523900, DequeueBufferDuration=514100, QueueBufferDuration=1073700, GpuCompleted=185817465094143,
I/Choreographer: Skipped 154 frames! The application may be doing too much work on its main thread.
W/RecyclerView: No adapter attached; skipping layout
I/OpenGLRenderer: Davey! duration=2957ms; Flags=0, IntendedVsync=12391732774600, Vsync=12394299441164, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=12394309810900, AnimationStart=12394309826300, PerformTraversalsStart=12394327757600, DrawStart=12394468721300, SyncQueued=12394483804300, SyncStart=12394518606400, IssueDrawCommandsStart=12394523119100, SwapBuffers=12394667312700, FrameCompleted=12394725342600, DequeueBufferDuration=6457800, QueueBufferDuration=19058700, GpuCompleted=2314885530818453536,
I/Choreographer: Skipped 122 frames! The application may be doing too much work on its main thread.

HTML content from the web is only partially obtained/displayed

I am running a downloaded tested code from an Android app development course by Rob Percival in Android studio.
The code is for fetching HTML content of a specified URL and displaying it in the logs.
It's the tested code provided by the author of the course.
The code runs fine but only a part of the HTML content of the specified URL is displayed in the logs.
These are the additional log entries I'm getting:
(After displaying partial html content)
I/art: Background sticky concurrent mark sweep GC freed 81(3KB) AllocSpace objects, 43(11MB) LOS objects, 37% free, 6MB/10MB, paused 1.012ms total 115.686ms
D/: HostConnection::get() New Host Connection established 0xa63c98c0, tid 10451
D/: HostConnection::get() New Host Connection established 0xa63c9d80, tid 10487
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/EGL_emulation: eglCreateContext: 0xa83cdf20: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0xa83cdf20: ver 2 0 (tinfo 0xa84e32d0)
D/EGL_emulation: eglMakeCurrent: 0xa83cdf20: ver 2 0 (tinfo 0xa84e32d0)
Any help would be appreciated.
Thanks.

Sudden app shutdown without doing any activity, throws IllegalStateException onMeasure()

My app always shutdown in random time interval (mostly from few minutes to something like 20 mins). The "App stopped working" messagebox appears. Biggest problem is, I don't do anything in app (like interacting with it), and it just random shutdown by itself. Here's logcat print:
07-15 20:34:16.595 27361-27363/test.game D/dalvikvm: GC_CONCURRENT freed 141
9K, 44% free 13902K/24391K, paused 4ms+9ms, total 66ms
07-15 20:34:28.997 27361-27363/test.game D/dalvikvm: GC_CONCURRENT freed 1416K, 43% free 13903K/24391K, paused 3ms+7ms, total 56ms
07-15 20:34:29.418 27361-27361/test.game D/AndroidRuntime: Shutting down VM
07-15 20:34:29.418 27361-27361/test.game W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x412b52a0)
07-15 20:34:29.498 27361-27361/test.game E/AndroidRuntime: FATAL EXCEPTION: main java.lang.IllegalStateException: onMeasure() did not set the measured dimension by calling setMeasuredDimension()
at android.view.View.measure(View.java:15293)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
at android.view.View.measure(View.java:15288)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
at android.view.View.measure(View.java:15288)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4876)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2397)
at android.view.View.measure(View.java:15288)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
at dalvik.system.NativeStart.main(Native Method)
One would say, it's because I didn't write setMeasuredDimension() when overriding method onMeasure(). Also, docs say you have to write this line to your onMeasure, otherwise the IllegalStateException will be thrown (see it here).
But I don't overriding onMeasure anywhere in my whole project, so problem is not here (at least not on my side in this case).
Few things to note:
this is full logcat log, and any of these lines ("at android. ...") doesn't link to my code, all goes to source - that means all of these links are gray
this exception always happens only on my S3 Mini (android 4.1.2), but never happened on my old Galaxy Ace S5830i (android 2.3.6) (and yes, I tested it alot - over 20hours on old phone and app still running!).
never happened in emulator
there are no "view resizing" operations running in background, which could cause this exception
I would like to post some code, but I have absolutely no idea where this exception could be thrown.
If someone can help, I'd be really, really grateful. I'm lost at this point...
Since there is not code, this is just a random guess. You can start by looking out for activities in which you've added fragments. It might be that the activity containing a fragment has been destroyed on the device due to inactivity for a long time(and memory requirements by the system, which I think is the reason that you are finding the bug on a device and not on the other). So the case is that the fragment might be referring to a view which might not be attached to the window now. (You can also look for views that use fragment adapters like viewPager, etc if you have used them).

I want the user to pass my login requirement in order to sign in

I want the intent I have below to be passed only when the user has passed the login requirements. I tried to put an if statement, in the onClick Listener but it wasn't working out. Basically, once the username and password meets my requirements, I want to pass the intent. If the intent doesn't pass, then I want to pass an else statement saying "That user doesn't exist."
10-20 16:53:10.330 2138-2138/com.squarespace.atpublishing.officialworkoutapp
I/art: Not late-enabling -Xcheck:jni (already on)
10-20 16:53:11.510 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 220ms
10-20 16:53:11.640 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background sticky concurrent mark sweep GC freed 1555(94KB) AllocSpace objects, 0(0B) LOS objects, 33% free, 417KB/623KB, paused 0 total 130ms
10-20 16:53:11.850 2138-2138/com.squarespace.atpublishing.officialworkoutapp W/art: Verification of boolean android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.onCreatePanelMenu(int, android.view.Menu) took 170ms
10-20 16:53:11.850 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 130ms
10-20 16:53:12.780 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 80ms
10-20 16:53:13.660 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 30ms
10-20 16:53:13.900 2138-2150/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 10ms
10-20 16:53:13.900 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background sticky concurrent mark sweep GC freed 1031(117KB) AllocSpace objects, 0(0B) LOS objects, 23% free, 781KB/1017KB, paused 10ms total 60ms
10-20 16:53:14.340 2138-2150/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 10ms
10-20 16:53:14.340 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background sticky concurrent mark sweep GC freed 282(24KB) AllocSpace objects, 0(0B) LOS objects, 13% free, 878KB/1017KB, paused 10ms total 80ms
10-20 16:53:14.460 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background partial concurrent mark sweep GC freed 297(33KB) AllocSpace objects, 0(0B) LOS objects, 36% free, 885KB/1397KB, paused 0 total 120ms
10-20 16:53:14.630 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 20ms
10-20 16:53:14.900 2138-2229/com.squarespace.atpublishing.officialworkoutapp D/OpenGLRenderer: Render dirty regions requested: true
10-20 16:53:14.950 2138-2138/com.squarespace.atpublishing.officialworkoutapp D/: HostConnection::get() New Host Connection established 0x7fb36d6b8620, tid 2138
10-20 16:53:14.960 2138-2138/com.squarespace.atpublishing.officialworkoutapp D/Atlas: Validating map...
10-20 16:53:15.260 2138-2229/com.squarespace.atpublishing.officialworkoutapp D/: HostConnection::get() New Host Connection established 0x7fb36d6ec100, tid 2229
10-20 16:53:15.350 2138-2229/com.squarespace.atpublishing.officialworkoutapp I/OpenGLRenderer: Initialized EGL, version 1.4
10-20 16:53:15.430 2138-2229/com.squarespace.atpublishing.officialworkoutapp D/OpenGLRenderer: Enabling debug mode 0
10-20 16:53:15.440 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/EGL_emulation: eglSurfaceAttrib not implemented
10-20 16:53:15.440 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb36d6b7b00, error=EGL_SUCCESS
10-20 16:53:15.620 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 30ms
10-20 16:53:15.650 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 39 frames! The application may be doing too much work on its main thread.
10-20 16:53:20.900 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 40ms
10-20 16:53:20.930 2138-2150/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 20ms
10-20 16:53:21.510 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 190ms
10-20 16:53:21.660 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 102 frames! The application may be doing too much work on its main thread.
10-20 12:53:24.100 2138-2150/com.squarespace.atpublishing.officialworkoutapp I/art: Background sticky concurrent mark sweep GC freed 278(36KB) AllocSpace objects, 0(0B) LOS objects, 11% free, 1242KB/1397KB, paused 0 total 190ms
10-20 12:53:25.100 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 70ms
10-20 12:53:26.510 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 30ms
10-20 12:53:27.000 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 20ms
10-20 12:53:27.330 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 149 frames! The application may be doing too much work on its main thread.
10-20 12:53:27.770 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/EGL_emulation: eglSurfaceAttrib not implemented
10-20 12:53:27.770 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb36d2e6900, error=EGL_SUCCESS
10-20 12:53:28.120 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 47 frames! The application may be doing too much work on its main thread.
10-20 12:53:28.220 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/EGL_emulation: eglSurfaceAttrib not implemented
10-20 12:53:28.220 2138-2229/com.squarespace.atpublishing.officialworkoutapp W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x7fb36d2e69c0, error=EGL_SUCCESS
10-20 12:53:28.270 2138-2138/com.squarespace.atpublishing.officialworkoutapp W/View: requestLayout() improperly called by android.support.design.internal.NavigationMenuView{2c5956e4 VFED.VC. ......ID 0,0-384,800} during layout: running second layout pass
10-20 12:53:28.460 2138-2145/com.squarespace.atpublishing.officialworkoutapp W/art: Suspending all threads took: 20ms
10-20 12:53:29.040 2138-2138/com.squarespace.atpublishing.officialworkoutapp I/Choreographer: Skipped 38 frames! The application may be doing too much work on its main thread.
`
Button mEmailSignInButton = (Button)
findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View view) {
attemptLogin();
if (mPasswordView.getText().toString().isEmpty() && mEmailSignInButton.getText().toString().isEmpty()){
Snackbar.make(view, "You Didn't enter anything", Snackbar.LENGTH_LONG).setAction("Action", null);
} else {
Intent intent = new Intent(LoginActivity.this, DrawerActivity.class);
startActivity(intent);
}
Intent intent = new Intent(LoginActivity.this, DrawerActivity.class);
startActivity(intent);
}
});
/**
* Attempts to sign in or register the account specified by the login form.
* If there are form errors (invalid email, missing fields, etc.), the
* errors are presented and no actual login attempt is made.
*/
private void attemptLogin() {
if (mAuthTask != null) {
return;
}
// Reset errors.
mEmailView.setError(null);
mPasswordView.setError(null);
// Store values at the time of the login attempt.
String email = mEmailView.getText().toString();
String password = mPasswordView.getText().toString();
boolean cancel = false;
View focusView = null;
// Check for a valid password, if the user entered one.
if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) {
mPasswordView.setError(getString(R.string.error_invalid_password));
focusView = mPasswordView;
cancel = true;
}
// Check for a valid email address.
if (TextUtils.isEmpty(email)) {
mEmailView.setError(getString(R.string.error_field_required));
focusView = mEmailView;
cancel = true;
} else if (!isEmailValid(email)) {
mEmailView.setError(getString(R.string.error_invalid_email));
focusView = mEmailView;
cancel = true;
}
if (cancel) {
// There was an error; don't attempt login and focus the first
// form field with an error.
focusView.requestFocus();
} else {
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
showProgress(true);
mAuthTask = new UserLoginTask(email, password);
mAuthTask.execute((Void) null)
}
}
Your attemptLogin(); needs to be called within the else { } of your if.
Currently, it's being called before your if, so it will attempt to login even if your email or password fields are empty.
This was probably just an oversight on your part. If not, you might want to brush on Java by doing the exercises on the following web site. http://codingbat.com/java

App crashes when Home or Back button press

So, my app crashes when I press Home button or Back button. I don't know how to solve this issue. Help!!!
public class Game extends SurfaceView implements SurfaceHolder.Callback {
public Game(Context context) {
super(context);
getHolder().addCallback(this);
gameContext = context;
}
...
public void surfaceDestroyed(SurfaceHolder holder) {
boolean retry = true;
updateThread.setRunning(false);
while (retry) {
try {updateThread.join();
retry = false; }
catch (InterruptedException e) {
}
}
}
}
And here is a log of process when I press Home button:
07-15 07:43:47.333: I/ActivityManager(285): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher} from pid 285
07-15 07:43:47.673: W/WindowManager(285): Screenshot failure taking screenshot for (290x515) to layer 21015
07-15 07:43:48.013: D/gralloc(36): Registering a buffer in the process that created it. This may cause memory ordering problems.
07-15 07:43:48.043: I/ARMAssembler(36): generated scanline__00000077:03010104_00008004_00000000 [ 84 ipp] (103 ins) at [0x4296eea0:0x4296f03c] in 599261 ns
07-15 07:43:48.464: D/gralloc(36): Registering a buffer in the process that created it. This may cause memory ordering problems.
07-15 07:43:48.504: I/ActivityManager(285): Config changes=1480 {1.0 310mcc260mnc en_US ldltr sw360dp w360dp h567dp 320dpi nrml port finger -keyb/v/h tball/v s.8}
07-15 07:43:48.574: I/InputReader(285): Reconfiguring input devices. changes=0x00000004
07-15 07:43:48.574: I/InputReader(285): Device reconfigured: id=0, name='qwerty2', size 720x1280, orientation 0, mode 1, display id 0
07-15 07:43:49.003: I/Choreographer(560): Skipped 168 frames! The application may be doing too much work on its main thread.
07-15 07:43:49.343: D/PhoneStatusBar(560): mSettingsPanelGravity = 55
07-15 07:43:49.593: D/dalvikvm(560): GC_FOR_ALLOC freed 7091K, 51% free 7087K/14336K, paused 111ms, total 131ms
07-15 07:43:49.743: W/WindowManager(285): Window freeze timeout expired.
07-15 07:43:49.743: W/WindowManager(285): Force clearing orientation change: Window{41ada620 u0 NavigationBar}
07-15 07:43:49.824: I/WindowManager(285): Screen frozen for +2s101ms due to Window{41ada620 u0 NavigationBar}
07-15 07:43:50.194: I/Choreographer(560): Skipped 124 frames! The application may be doing too much work on its main thread.
07-15 07:43:50.803: I/Choreographer(400): Skipped 119 frames! The application may be doing too much work on its main thread.
07-15 07:43:51.783: I/Choreographer(400): Skipped 106 frames! The application may be doing too much work on its main thread.
07-15 07:43:52.493: I/Choreographer(560): Skipped 194 frames! The application may be doing too much work on its main thread.
07-15 07:43:53.105: W/IInputConnectionWrapper(799): showStatusIcon on inactive InputConnection
07-15 07:43:54.173: D/dalvikvm(285): GC_EXPLICIT freed 3158K, 52% free 5244K/10724K, paused 5ms+11ms, total 134ms
try releasing resources which are consuming memory whenever they are in no use and you can do this in onPause() methods
you can also make some changes in manifiest.xml file like this
<activity android:name="your.package.name.YourActivity" android:configChanges="orientation|keyboard|keyboardHidden|screenLayout|uiMode|screenSize|smallestScreenSize" android:screenOrientation="landscape">
...

Categories

Resources