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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:24:01+00:00 2026-06-17T04:24:01+00:00

I have an activity for my menu events: public class GlobalMenu extends Activity{ private

  • 0

I have an activity for my menu events:

public class GlobalMenu extends Activity{

    private MenuItem item;

    public boolean event(MenuItem item){
        this.item = item;
        // Handle item selection
        switch (this.item.getItemId()) {
            case R.id.menu_stop:
                finish();
                return true;
        }
        return true;
    }
}

And I use it like this

GlobalMenu gm = new GlobalMenu();

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    return gm.event(item);
}

But the finish didn’t work, I think I need to link it with an application but I don’t know how to do

Thanks

  • 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-17T04:24:03+00:00Added an answer on June 17, 2026 at 4:24 am

    First of All, You can’t make a Object or Instance of Android Activity.
    like this

    GlobalMenu gm = new GlobalMenu();
    

    You have to pass a Context of GlobalMenu Activity to other Activity or Class and then call finish on this.

    Like,

    ((GlobalMenu)mContext).finish();
    

    Here mContext is a reference of GlobalMenu Activity.

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

Sidebar

Related Questions

I have a class that extends Activity and within it got a private class
I have an activity: public class Notepadv1 extends ListActivity { public static final int
I have Fragment activity with pager: List<Fragment> fragments = new Vector<Fragment>(); fragments.add(Fragment.instantiate(this, PastEventListFragment.class.getName(),bundle)); fragments.add(Fragment.instantiate(this,
So, I have this code: package com.example.ponto_2d; import android.app.Activity; import android.view.Menu; import android.view.MotionEvent; import
I have ordinary activity with Option Menu, which I created by this code: @Override
I have a main activity, that holds the main menu. This menu has an
I have a main menu activity with a bunch of buttons. One button starts
I have created an Activity that will behave like a popup menu is actually
I am developing an activity which have an Update button as menu for android.
My problem is how to switch from context menu to correct activity. 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.