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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:21:46+00:00 2026-06-14T21:21:46+00:00

I want to finish the activity when received complete response from server in another

  • 0

I want to finish the activity when received complete response from server in another java class.

Category.java

This is main activity

public void onListItemClick(ListView parent, View v, int position, long id)
    {
        // Get the selected category id & name.
        String catId = "";
        String catName = "";
        LinearLayout ll = (LinearLayout)findViewById(R.id.linearLayout1);
        View view = ll.getChildAt(0);
        if(view instanceof ListView) {
            ListView lView = (ListView) view;
            RowData rowData = (RowData) lView.getAdapter().getItem(position);
            catId = rowData.mCatId;
            catName = rowData.mTitle;
        }

        String url = "http://global.thinlenses.co.uk/virtualMirror/productlisting.php"; 
        String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<category><Id>" + catId + "</Id>"
                    + "<Data>" + "pList" + "</Data></category>";

        if(getIntent().getBooleanExtra("VM", false))
            new SpinnerHelper().serverCall(Category.this, "ProductListVM", url, xml, catName);
        else
            new SpinnerHelper().serverCall(Category.this, "ProductList", url, xml, catName);
    }

SpinnerHelper.java Regular Class not Activity

void serverCall(Context context, final String target, final String url, final String xml, String extraValue)
    {
        try {
            this.context = context;
            this.target = target;
            this.extraValue = extraValue;

            ConnectivityManager conMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
            if(conMan.getActiveNetworkInfo() != null && conMan.getActiveNetworkInfo().isConnected())
            {
                dialog = new ProgressDialog(context);
                dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                dialog.setCancelable(true);
                dialog.setTitle(R.string.app_name);
                dialog.setMessage(context.getString(R.string.progressing));
                dialog.show();

                // Create a thread for updating the spinner.
                Thread progressThread = new Thread(new Runnable() {
                    public void run() {
                        try {
                            while(!isExecuted) {
                                Thread.sleep(1000);                                 // Wait 1000ms between each update.
                                handler.sendMessage(handler.obtainMessage());       // Active the update handler.
                            }
                        }
                        catch (InterruptedException e) {
                            Log.e("VM", "Exception while spinner is updating at: " + e.getMessage());
                        }
                    }
                });
                progressThread.start();

                // Create a thread to get response from server.
                Thread registerThread = new Thread(new Runnable() {
                    public void run()
                    {
                        // Get response XML from server and parse it.
                        String resXML = new Connection().getResponse(url, xml);
                        XMLParser parser = new XMLParser();
                        Document doc = parser.getDomElement(resXML);
                        if(doc != null)
                        {
                            if(target.equals("Category")) {
                                NodeList nodeList = doc.getElementsByTagName("Category");
                                name = new String[nodeList.getLength()];
                                id = new String[nodeList.getLength()];

                                // Fetch all node values and store into arrays.
                                for(int index = 0; index < nodeList.getLength(); index++)
                                {
                                    Element element = (Element) nodeList.item(index);
                                    id[index] = parser.getValue(element, "id");
                                    name[index] = parser.getValue(element,"CategoryName");
                                }
                                result = "yes";
                            }
    }

}

This handler is called when i recieved complete reponse from server.

  Handler handler = new Handler()
  {
    public void handleMessage(Message message)
    {
        if(isExecuted)
        {
            dialog.dismiss();
            isExecuted = false;

            if(result.equals("yes"))
            {
                  /////HERE i want to start the next activity and finish the Category(previous activity).

             }
  • 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-14T21:21:48+00:00Added an answer on June 14, 2026 at 9:21 pm

    you can use your context reference for this

    Intent intent = new Intent(context,nextActivity.class);
    context.startActivity(intent);
    ((Activity) context).finish();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to finish one activity from another activity, like: In Activity [A], on
I want to sent intent from one first activity to another. The first activity
I want to finish the Activity on Home Button Click . I have below
i m using the following code to finish an activity but i want to
An activity opens the SurfaceView class passing the context. I want to close de
I want to finish my app calling the first activity with Intent.FLAG_ACTIVITY_CLEAR_TOP and finishing
I am using an activity to capture image i want to start a finish
I am creating an Activity with android:launchMode=singleTask. In the app, there is another class,
Hi I want to finish previously opened activity on current activity . There is
is there any way, how to finish certain activity from a stack? I have

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.