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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:27:54+00:00 2026-06-05T00:27:54+00:00

If I have a class with a single constructor, how can I get Roboguice

  • 0

If I have a class with a single constructor, how can I get Roboguice to inject this into an activity?

The service to be injected:

public FlightManager(Context context){
    //do something with the context
}

The activity:

public class recordFlight extends RoboActivity {

    @InjectResource FlightManager manager;

  //whatever code here
}

The only dependency is the Context, which I gather should be injected without problem. Additoinally, all of my other usages, such as @InjectView and @Inject of classes with a default constructor seem fine, but the usage above kills the app without even giving me a stack trace.

Any ideas?

Thanks

Jon

  • 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-05T00:27:56+00:00Added an answer on June 5, 2026 at 12:27 am

    Mark the constructor with the @Inject annotation:

    @Inject
    public FlightManager(Context context){
        //do something with the context
    }
    

    Then inject FlightManager like so:

    public class recordFlight extends RoboActivity {
    
        @Inject FlightManager manager;
    
        //whatever code here
    }
    

    @InjectResource is not necessary here, since it’s a regular Java class you’re injecting, not an Android resource.

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

Sidebar

Related Questions

i have one single class for margin and i am using this class to
I have a Repository Class with the following method... public T Single<T>(Predicate<T> expression) {
I have an Assembly(A) which defines a Managed class which has a public constructor
I have a class that takes an array of interfaces in the constructor: public
Given that I have a class Base that has a single argument constructor with
We have 2 tables: Table Authority: public class Authority { public int ID {get;set;}
let's have these classes: public class MyObject { //constructor and other stuff public bool
This is what I have so far: public class Numbers { // Fields public
I have the interface defined as below and is implemented by a single class
For a newsroom system I have a class that contains a single news story.

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.