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 7799873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:26:49+00:00 2026-06-02T00:26:49+00:00

There are 2 Classes and 1 Interface: Class 1 = LoginPage, Class 2 =

  • 0

There are 2 Classes and 1 Interface: Class 1 = LoginPage, Class 2 = SyncData and Interface = AsyncTaskCompleteListener.

Class 1 uses Class 2 to sync information with the server. After Class 2 posts the result information in the onPostExecute method, the Interface callback method will be used to send the result information to Class 1. When I try to use the callback method, I get to see the following error:

04-12 11:06:43.715: W/dalvikvm(24941): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
04-12 11:06:43.720: E/AndroidRuntime(24941): FATAL EXCEPTION: main
04-12 11:06:43.720: E/AndroidRuntime(24941): java.lang.NullPointerException
04-12 11:06:43.720: E/AndroidRuntime(24941):    at com.on_d_mand.live_evenementen.SyncData.onPostExecute(SyncData.java:101)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at com.on_d_mand.live_evenementen.SyncData.onPostExecute(SyncData.java:1)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at android.os.AsyncTask.finish(AsyncTask.java:417)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at android.os.AsyncTask.access$300(AsyncTask.java:127)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at android.os.Looper.loop(Looper.java:130)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at android.app.ActivityThread.main(ActivityThread.java:3691)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at java.lang.reflect.Method.invokeNative(Native Method)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at java.lang.reflect.Method.invoke(Method.java:507)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
04-12 11:06:43.720: E/AndroidRuntime(24941):    at dalvik.system.NativeStart.main(Native Method)

Class 1 onTaskComplete method sample:

public void onTaskComplete(String result) {
    //perform action after receiving the information
    Toast.makeText(this, result, Toast.LENGTH_LONG).show(); 
}

Class 2 onPostExecute method sample:

public void onPostExecute(String RESULT) {

    if(dialog.isShowing()){
        dialog.dismiss();
    }

    callback.onTaskComplete(RESULT);

}

Class 3:

package com.on_d_mand.live_evenementen;

public interface AsyncTaskCompleteListener<T> {
    public void onTaskComplete(T result);
}

Does anyone knows what I’m doing wrong here? I hope it’s not too complicated with the Classes and the Interface.

Edit

The solution for this problem was by initialising the callback object in the Class 2 contructor.

  • 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-02T00:26:51+00:00Added an answer on June 2, 2026 at 12:26 am

    You need to pass a reference to an object that implements your listener to your ‘SyncData’ class when you create it. Presumably, at the moment in your LoginPage you have something that looks like this:

     new SyncData().execute();
    

    You need to change this to:

     new SyncData(this).execute();
    

    And add a constructor to SyncData:

     public SyncData(AsyncTaskCompleteListener<String> callback)
     {
          this.callback = callback;
     }
    

    If you already have a constructor for SyncData, you will instead need to add the argument and code to the existing constructor.

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

Sidebar

Related Questions

There are many classes having this provider suffix. (Data,membership,modelmetadata,...). When should be a class
Are there any other classes provided by php5+ such as the mysqli() class? for
For example, there is a interface IMyInterface , and three classes support this interface:
Consider, I have the following 3 classes / interfaces: class MyClass<T> { } interface
Possible Duplicates: Abstract class and Interface class? Java: interface / abstract classes / abstract
This is one of the classes in Interface file. [DataContract] public class ClassX {
Following classes are created, no interface/abstract class for now: Test - for creating test
The classes: public interface Inter { ...some methods... } public class Impl implements Inter
I have this classes: interface Info{} class AInfo : Info { } class BInfo
Are there any easy-to-use , high-level classes or libraries that let you interact with

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.