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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:33:19+00:00 2026-06-07T03:33:19+00:00

Application closed after few seconds. I can see the JSON value in logcat but

  • 0

Application closed after few seconds. I can see the JSON value in logcat but result is not updating in listview.

my main activity class code below:

public class MainActivity extends ListActivity {
    private ProgressDialog dialog;
    private static String url="url here";


    private static final String BASE_TAG="base";
    private static final String RATES_TAG="rates";

    JSONParser jParser=new JSONParser();

    ArrayList<HashMap<String,String>> currentRates;

    JSONArray rates=null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        currentRates=new ArrayList<HashMap<String,String>>();

        new getRates().execute();

        ListView lv=getListView();


    }

    public class getRates extends AsyncTask<String,String,String>{

    @Override
    protected void onPreExecute(){
        super.onPreExecute();
        dialog=new ProgressDialog(MainActivity.this);
        dialog.setMessage("Please wait");
        dialog.setIndeterminate(false);
        dialog.setCancelable(false);
        dialog.show();
    }

        @Override
        protected String doInBackground(String... args) {

List<NameValuePair> params=new ArrayList<NameValuePair>();

JSONObject json=jParser.makeHttpRequest(url,"GET",params);

Log.d("Current Rates:",json.toString());

try {
    rates=json.getJSONArray(RATES_TAG);

    for(int i=0;i<rates.length();i++){
        JSONObject c=rates.getJSONObject(i);


        String rates=c.getString(RATES_TAG);

        HashMap<String,String>map=new HashMap<String,String>();

        map.put(RATES_TAG, rates);

        currentRates.add(map);
    }
} catch (JSONException e){
    e.printStackTrace();
}

            return null;
        }

        protected void onPostExecute(String url){
            dialog.dismiss();

            runOnUiThread(new Runnable(){
                public void run(){
                    ListAdapter adapter=new SimpleAdapter(MainActivity.this, currentRates ,R.layout.rates_item,new String[]{RATES_TAG},new int[]{R.id.rates});

                    setListAdapter(adapter);
                }
            });
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }


}

Here is my logcat report:

> 07-08 19:46:13.103: E/AndroidRuntime(331): FATAL EXCEPTION: AsyncTask
> #1 07-08 19:46:13.103: E/AndroidRuntime(331): java.lang.RuntimeException: An error occured while executing
> doInBackground() 07-08 19:46:13.103: E/AndroidRuntime(331):   at
> android.os.AsyncTask$3.done(AsyncTask.java:200) 07-08 19:46:13.103:
> E/AndroidRuntime(331):    at
> java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
> 07-08 19:46:13.103: E/AndroidRuntime(331):    at
> java.util.concurrent.FutureTask.setException(FutureTask.java:125)
> 07-08 19:46:13.103: E/AndroidRuntime(331):    at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
> 07-08 19:46:13.103: E/AndroidRuntime(331):    at
> java.util.concurrent.FutureTask.run(FutureTask.java:138) 07-08
> 19:46:13.103: E/AndroidRuntime(331):  at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
> 07-08 19:46:13.103: E/AndroidRuntime(331):    at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
> 07-08 19:46:13.103: E/AndroidRuntime(331):    at
> java.lang.Thread.run(Thread.java:1019) 07-08 19:46:13.103:
> E/AndroidRuntime(331): Caused by: java.lang.NullPointerException 07-08
> 19:46:13.103: E/AndroidRuntime(331):  at
> com.razzil.currency.MainActivity$getRates.doInBackground(MainActivity.java:69)
> 07-08 19:46:13.103: E/AndroidRuntime(331):    at
> com.razzil.currency.MainActivity$getRates.doInBackground(MainActivity.java:1)
> 07-08 19:46:13.103: E/AndroidRuntime(331):    at
> android.os.AsyncTask$2.call(AsyncTask.java:185) 07-08 19:46:13.103:
> E/AndroidRuntime(331):    at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
> 07-08 19:46:13.103: E/AndroidRuntime(331):    ... 4 more 07-08
> 19:46:15.372: E/WindowManager(331): Activity
> com.razzil.currency.MainActivity has leaked window
> com.android.internal.policy.impl.PhoneWindow$DecorView@40520830 that
> was originally added here 07-08 19:46:15.372: E/WindowManager(331):
> android.view.WindowLeaked: Activity com.razzil.currency.MainActivity
> has leaked window
> com.android.internal.policy.impl.PhoneWindow$DecorView@40520830 that
> was originally added here 07-08 19:46:15.372: E/WindowManager(331):
>   at android.view.ViewRoot.<init>(ViewRoot.java:258) 07-08
> 19:46:15.372: E/WindowManager(331):   at
> android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
> 07-08 19:46:15.372: E/WindowManager(331):     at
> android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
> 07-08 19:46:15.372: E/WindowManager(331):     at
> android.view.Window$LocalWindowManager.addView(Window.java:424) 07-08
> 19:46:15.372: E/WindowManager(331):   at
> android.app.Dialog.show(Dialog.java:241) 07-08 19:46:15.372:
> E/WindowManager(331):     at
> com.razzil.currency.MainActivity$getRates.onPreExecute(MainActivity.java:59)
> 07-08 19:46:15.372: E/WindowManager(331):     at
> android.os.AsyncTask.execute(AsyncTask.java:391) 07-08 19:46:15.372:
> E/WindowManager(331):     at
> com.razzil.currency.MainActivity.onCreate(MainActivity.java:43) 07-08
> 19:46:15.372: E/WindowManager(331):   at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
> 07-08 19:46:15.372: E/WindowManager(331):     at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
> 07-08 19:46:15.372: E/WindowManager(331):     at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
> 07-08 19:46:15.372: E/WindowManager(331):     at
> android.app.ActivityThread.access$1500(ActivityThread.java:117) 07-08
> 19:46:15.372: E/WindowManager(331):   at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
> 07-08 19:46:15.372: E/WindowManager(331):     at
> android.os.Handler.dispatchMessage(Handler.java:99) 07-08
> 19:46:15.372: E/WindowManager(331):   at
> android.os.Looper.loop(Looper.java:123) 07-08 19:46:15.372:
> E/WindowManager(331):     at
> android.app.ActivityThread.main(ActivityThread.java:3683) 07-08
> 19:46:15.372: E/WindowManager(331):   at
> java.lang.reflect.Method.invokeNative(Native Method) 07-08
> 19:46:15.372: E/WindowManager(331):   at
> java.lang.reflect.Method.invoke(Method.java:507) 07-08 19:46:15.372:
> E/WindowManager(331):     at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
> 07-08 19:46:15.372: E/WindowManager(331):     at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 07-08
> 19:46:15.372: E/WindowManager(331):   at
> dalvik.system.NativeStart.main(Native Method)
  • 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-07T03:33:20+00:00Added an answer on June 7, 2026 at 3:33 am

    You are hitting NULLPOINTEREXCEPTION in your MainActivity line no 69. it is in doInBackground method. debug it and see what value is null and causing the issue.

    > java.lang.Thread.run(Thread.java:1019) 07-08 19:46:13.103:
    > E/AndroidRuntime(331): Caused by: java.lang.**NullPointerException** 07-08
    > 19:46:13.103: E/AndroidRuntime(331):  at
    > com.razzil.currency.MainActivity$getRates.doInBackground(MainActivity.java:69)
    > 07-08 19:46:13.103: E/AndroidRuntime(331):    at
    > com.razzil.currency.MainActivity$getRates.doInBackground(MainActivity.java:1)
    > 07-08 19:46:13.103: E/AndroidRuntime(331): 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After I close my application fbclient.dll remains in memory for about 3 seconds. So
after reading a few articles, I am still not sure I understand Multi-threading to
After an HTTP POST (generated by an application, not by users) I want to
I am trying to determine if my application is closed through clicking the X
I am working on customizing a closed source client application. It has a tree
In my standalone GUI application, I will install a Windows Closed handle on the
I have an MFC application, which i don't want to be closed during the
How or where can I run a command when the application closes, even if
After a few weekends exploring Clojure I came up with this program. It allows
Done a bit of Googling, but not quite finding what I want. In an

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.