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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:44:43+00:00 2026-05-23T09:44:43+00:00

I had created a class with some stuff I commonly use, like toasts or

  • 0

I had created a class with some stuff I commonly use, like toasts or dialogs. I named this class MyUtils. I had the following lines of code inside MyUtils. Where subYesNoDialogResult is a private variable of type boolean.

public void subYesNoDialog(Context appctx,String title,String mymessage)    {
   AlertDialog.Builder builder = new AlertDialog.Builder(appctx);
   builder.setMessage(mymessage)
     .setTitle(title)
     .setCancelable(false)
     .setPositiveButton(android.R.string.yes,
       new DialogInterface.OnClickListener(){
         public void onClick(DialogInterface dialog, int id) {
           subYesNoDialogResult = true;
         }
     })
     .setNegativeButton(android.R.string.no,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           subYesNoDialogResult = false;
           dialog.cancel();
         }
     });
     AlertDialog alert = builder.create();      
     alert.show();
}

I had another class which is used help the main activity class for certain purpose. I call this class MyDbHelper. I tried to call the above function to show up a Yes/No dialog. This is specifically to get the user’s input to make a decision before doing some process inside MyDbHelper class. But I get NullPointerException on doing this. Here is my logcat out put.

I/ActivityManager(   67): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.xxx.geolog/.GeologActivity }
D/AndroidRuntime(  676): Shutting down VM
D/dalvikvm(  676): Debugger has detached; object registry had 1 entries
I/ActivityManager(   67): Start proc com.xxx.geolog for activity com.xxx.geolog/.GeologActivity: pid=683 uid=10040 gids={}
I/AndroidRuntime(  676): NOTE: attach of thread 'Binder Thread #3' failed
D/dalvikvm(   33): GC_EXPLICIT freed 244 objects / 9464 bytes in 704ms
D/dalvikvm(   33): GC_EXPLICIT freed 2 objects / 64 bytes in 350ms
D/dalvikvm(   33): GC_EXPLICIT freed 2 objects / 48 bytes in 536ms
W/GpsLocationProvider(   67): Duplicate add listener for uid 10040
W/WindowManager(   67): Attempted to add window with non-application token WindowToken{44f7d2a0 token=null}.  Aborting.
D/AndroidRuntime(  683): Shutting down VM
W/dalvikvm(  683): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime(  683): FATAL EXCEPTION: main
E/AndroidRuntime(  683): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
E/AndroidRuntime(  683):    at android.view.ViewRoot.setView(ViewRoot.java:509)
E/AndroidRuntime(  683):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
E/AndroidRuntime(  683):    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/AndroidRuntime(  683):    at android.app.Dialog.show(Dialog.java:241)
E/AndroidRuntime(  683):    at com.xxx.geolog.SubLocationListener.onProviderDisabled(SubLocationListener.java:33)
E/AndroidRuntime(  683):    at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:204)
E/AndroidRuntime(  683):    at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:124)
E/AndroidRuntime(  683):    at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:140)
E/AndroidRuntime(  683):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  683):    at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime(  683):    at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime(  683):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  683):    at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime(  683):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime(  683):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime(  683):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(   67):   Force finishing activity com.xxx.geolog/.GeologActivity
W/ActivityManager(   67): Activity pause timeout for HistoryRecord{45030820 com.xxx.geolog/.GeologActivity}

How can I fix this? Did I do something wrong?

  • 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-05-23T09:44:43+00:00Added an answer on May 23, 2026 at 9:44 am

    Are you trying to use the application context to show a dialog?
    If so try to use an activity context instead to see if it makes a difference.

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

Sidebar

Related Questions

I had created one HTML page for my experiance. In this i had use
For this assignment I had to create my own string class. I initially wrote
I had created a new console application in VS 2010. I had written some
I've had problems with this before but now it's somehow working. Now I've following
I already had this stuff working in another project but now it does not.
I recently had an idea to create my own String class to make using
So for my programming class we have had a project to create a virtual
I had created a zip file (together with directory) under Windows as follow (Code
Doug McCune had created something that was exactly what I needed ( http://dougmccune.com/blog/2007/05/10/analyze-your-actionscript-code-with-this-apollo-app/ )
I have a smallish utility library I made that I had created in TFS

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.