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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:54:08+00:00 2026-06-06T09:54:08+00:00

Usually, in order to launch a new Activity and get its result, from an

  • 0

Usually, in order to launch a new Activity and get its result, from an Activity class, I will use

public void startActivityForResult (Intent intent, int requestCode)

However, what if I try to launch a new Activity and get its result, from a non-Activity class? How I can achieve this?

The reason I ask so as I am currently having LoginManager class (A non-Activity class). It is having the following code.

    accountManager.getAccountManager().getAuthToken(account, AUTH_TOKEN_TYPE, true, new AccountManagerCallback<Bundle>() {
        public void run(AccountManagerFuture<Bundle> future) {
            try {
                Bundle bundle = future.getResult();
                if (bundle.containsKey(AccountManager.KEY_INTENT)) {
                    Intent intent = bundle.getParcelable(AccountManager.KEY_INTENT);
                    intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
                    // Compilation error, as LoginManager doesn't have startActivityForResult method.
                    startActivityForResult(intent, REQUEST_AUTHENTICATE);
  • 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-06T09:54:10+00:00Added an answer on June 6, 2026 at 9:54 am

    ((Activity) mContext).startActivityForResult(.....) will do the trick.

    But results will be delivered to the actual activity holding the context.

    You can apply following Approach

    Create single argument constructor in LoginManager class like follows.

    class LoginManager
    {
      private Context mContext; 
      LoginManager(Context mContext)
      {
        this.mContext=mContext;
      }
      .............................
      //Then whenever you want to call method call like this.
    
      ((Activity) mContext).startActivityForResult(.....)
    
    }
    

    Now in Activity class whenever you will create Object of LoginManager class create as follows.

    LoginManager loginManager=new LoginManager(ActivityName.this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order to use SetWindowsHookEx in a GUI application, you usually want in the
I usually use 4 white spaces to indent C programs, but in order to
Usually, I use SELECT * FROM tableName WHERE fieldName LIKE '%string%' to find every
Usually, in order to find how two binary files are different, I use diff
From within my buddypress PHP templates I usually get the username of any given
Usually, when A is inheriting from B , all the members of A are
Usually it will ignore C files that are not documented, but I'd like to
I'm getting used to Haskell's higher-order functions. Usually I can replace explicit patterns of
Usually, I need to retrieve data from a table in some range; for example,
I usually use sql parameters with queries, but in this case I need to

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.