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

  • Home
  • SEARCH
  • 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 8438903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:51:03+00:00 2026-06-10T07:51:03+00:00

when im running an method from an asynctask, my application crashes. But i am

  • 0

when im running an method from an asynctask, my application crashes. But i am not sure why, the error log isn’t really elaborate as well, which makes it harder to find the problem.

It has something to do with the context, can anyone find what i am doing wrong?

public class UpdateHelpers extends Activity{

public String UPDATE_TIMESTAMP; 

    //opgeslagen timestamp verkrijgen
    public int getLastUpdateTimeStamp(){
        System.out.println(" getLastUpdateTimestamp Methode" );
          SharedPreferences savedTimeStamp = getSharedPreferences(UPDATE_TIMESTAMP,  MODE_PRIVATE);
          Integer startvalue = 1343192400; // timestamp last file from assets: (25-07-2012)
           Integer timestamp = savedTimeStamp.getInt("timestamp", startvalue); //standaard value: datum laatste json uit assets (25-07-2012)
           System.out.println("return value: "+timestamp);
           return timestamp;
        }

Class is bigger, more helping methods, but this already doesnt work)

In the Async task (do in background)

//check for updates
                    Integer ts = uh.getLastUpdateTimeStamp();
                    System.out.println("value of timestamp= "+ts);

where uh is declared in the onCreate of the class with the async task:

 public UpdateHelpers uh;
 uh = new UpdateHelpers();

What i need is an saved timestamp, and if it doesnt exist the timestamp from when i downloaded an file (on 25 juli). Then i can check if there is an update with another method, but my code crashes earlier.

I put in some system.out.printlns, so you can see where it goes wrong
Here is my crash log:

08-26 16:14:54.932: I/System.out(12571):  getLastUpdateTimestamp Methode
08-26 16:14:54.932: W/dalvikvm(12571): threadid=8: thread exiting with uncaught exception (group=0x400259f8)
08-26 16:14:54.942: E/AndroidRuntime(12571): FATAL EXCEPTION: AsyncTask #1
08-26 16:14:54.942: E/AndroidRuntime(12571): java.lang.RuntimeException: An error occured while executing doInBackground()
08-26 16:14:54.942: E/AndroidRuntime(12571):    at android.os.AsyncTask$3.done(AsyncTask.java:200)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at java.lang.Thread.run(Thread.java:1102)
08-26 16:14:54.942: E/AndroidRuntime(12571): Caused by: java.lang.NullPointerException
08-26 16:14:54.942: E/AndroidRuntime(12571):    at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:146)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at com.hera.ontdekdelft.UpdateHelpers.getLastUpdateTimeStamp(UpdateHelpers.java:24)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at com.hera.ontdekdelft.StartUp$LoadData.doInBackground(StartUp.java:611)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at com.hera.ontdekdelft.StartUp$LoadData.doInBackground(StartUp.java:1)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
08-26 16:14:54.942: E/AndroidRuntime(12571):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-26 16:14:54.942: E/AndroidRuntime(12571):    ... 4 more

Anyone an idea?
I didn’t put in my whole code because its a lot.
Thank you!

  • 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-10T07:51:05+00:00Added an answer on June 10, 2026 at 7:51 am

    You cannot initialize a activity class like below. It needs to be initialized by the Android for you

    uh = new UpdateHelpers();
    

    uh should be your Activity. Do something like this

    uh = ActivityName.this
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im running a console app that loads a dll and calls a method from
I have a particularly long running method that I need to execute from my
How does the .cancel(boolean) method of a running AsyncTask work? Here is the documentation:
I want to disable a method from running if my audio clip is playing.
I have written a database class but can't access the method from within: class
I have a long running method which can take a minute. On my local,
When running the method: CFReadStreamSetProperty(theReadStream, kCFStreamPropertySSLSettings (CFDictionaryRef)tlsPacket->tlsSettings); To secure the connection of a CFReadStream,
I have a method running on the EDT and within that I want to
I am running a method that takes a (char,double,char) and returns a double or
I have a simple method (running on Tomcat 6.0.35) that looks like so: @RequestMapping(value

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.