Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8402827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:10:28+00:00 2026-06-09T22:10:28+00:00

I used this sample code in a similar clock application: http://about-android.blogspot.in/2010/04/create-apps-to-show-digital-time-in_19.html It works fine,

  • 0

I used this sample code in a similar clock application:
http://about-android.blogspot.in/2010/04/create-apps-to-show-digital-time-in_19.html

It works fine, however when using the back or home buttons I get a nullpointerexception in the log. It says unable to stop application.
If I remove the methods :

timer.cancel();
timer.purge();
timer = null;

It works OK, but I suppose this would be memory consuming?
/M

08-19 19:00:13.438: E/AndroidRuntime(1064): FATAL EXCEPTION: main
08-19 19:00:13.438: E/AndroidRuntime(1064): java.lang.RuntimeException: Unable to stop activity {se.macke.binarycounter/se.macke.binarycounter.MainActivity}: java.lang.NullPointerException
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2624)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2690)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.app.ActivityThread.access$2100(ActivityThread.java:117)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:964)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.os.Handler.dispatchMessage(Handler.java:99)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.os.Looper.loop(Looper.java:123)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-19 19:00:13.438: E/AndroidRuntime(1064): at java.lang.reflect.Method.invokeNative(Native Method)
08-19 19:00:13.438: E/AndroidRuntime(1064): at java.lang.reflect.Method.invoke(Method.java:507)
08-19 19:00:13.438: E/AndroidRuntime(1064): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-19 19:00:13.438: E/AndroidRuntime(1064): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-19 19:00:13.438: E/AndroidRuntime(1064): at dalvik.system.NativeStart.main(Native Method)
08-19 19:00:13.438: E/AndroidRuntime(1064): Caused by: java.lang.NullPointerException
08-19 19:00:13.438: E/AndroidRuntime(1064): at se.macke.binarycounter.MainActivity.onStop(MainActivity.java:209)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.app.Instrumentation.callActivityOnStop(Instrumentation.java:1170)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.app.Activity.performStop(Activity.java:3873)
08-19 19:00:13.438: E/AndroidRuntime(1064): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2619)
08-19 19:00:13.438: E/AndroidRuntime(1064): … 11 more
08-19 19:00:16.398: I/Process(1064): Sending signal. PID: 1064 SIG: 9
08-19 19:00:16.450: I/ActivityManager(61): Process se.macke.binarycounter (pid 1064) has died.
08-19 19:00:16.450: E/InputDispatcher(61): channel ‘4079da00 se.macke.binarycounter/se.macke.binarycounter.MainActivity (server)’ ~ Consumer closed input channel or an error occurred. events=0x8
08-19 19:00:16.450: E/InputDispatcher(61): channel ‘4079da00 se.macke.binarycounter/se.macke.binarycounter.MainActivity (server)’ ~ Channel is unrecoverably broken and will be disposed!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:10:30+00:00Added an answer on June 9, 2026 at 10:10 pm

    The visible lifetime of an Activity is between onStart() and onStop(). By setting your timer to null and then using the back button or the home button and accessing the application again doesn’t ensure that the Activity had terminated, it simply wasn’t visible anymore. So you end up accessing something that is pointing to null and hence the NPE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my sample code, however I used HttpProtocolParams.setContentCharset(params, utf-8); im my code but
I am developing a simple sip-based voip app for android. I used this sample
i used this code: List<string> lists=new List<string>(apple,orange,banana,apple,mang0,orange); string names; names=lists.Distinct() is that correct?
I used this MSDN example to construct my console host app: http://msdn.microsoft.com/en-us/library/ms731758.aspx It works
I used this tutorial to create a basic Javascript function for implementing change during
I used the code below to create a TableRow with content dynamically. It works
Apple used to have EditableDetailView as sample code to learn how to do editable
I'm completely stumped, I've used very similar code before and it worked perfectly, the
Recently I've been writing code similar to this: messagehandler.h: #include message.h class MessageHandler {
I have a simple challenge with a background not animating. I have used this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.