Questions tagged [roboguice]

Roboguice brings the power and testability of using the Google Guice dependency injection framework to Android application development.

RoboGuice is a framework that brings the simplicity and ease of Dependency Injection to Android, using Google's own Guice library.

Useful links

329 questions
4
votes
0 answers

How to use RoboDialogFragment with a custom layout

Can anybody tell me, point e at an example or demo or how to use RoboDialogFragment to inject views on a custom DialogFragment? (Any help or examples in the area of roboguice and fragments would help!) I'm implementing RoboDialogFragment, overriding…
Matt Whetton
  • 6,616
  • 5
  • 36
  • 57
4
votes
1 answer

Inject object with constructor that takes a parameter using RoboGuice 2

I am trying out RoboGuice2 for Android (and Guice for that matter) for the first time and am stuck right now. I have been unable to find an example of how to do this and would love for somebody to show me the correct way with explanation. I want…
jjNford
  • 5,170
  • 7
  • 40
  • 64
4
votes
1 answer

How do I override injected @Singleton classes with robolectric?

I have a fragment that I am trying to test using Robolectric (and Mockito) which uses a @Singleton api class. I am trying to mock the singleton in a way where I can customize the response for each test. Here is my API class that my fragment…
BoredAndroidDeveloper
  • 1,251
  • 1
  • 11
  • 26
4
votes
1 answer

Roboguice injection and Provider class

In RoboGuice examples there are two different ways to inject something @Inject protected LayoutInflater inflater; @Inject protected Provider inflater2; What's the difference between them and what way and when i need to choose?
Dmitriy Tarasov
  • 1,949
  • 20
  • 37
4
votes
2 answers

Roboguice injection into adapter

I have an adapter which extends ArrayAdapter and want to inject into them LayoutInflater. Code presented below, but inflater is always null public abstract class MyAdapter extends ArrayAdapter { @Inject protected LayoutInflater…
Dmitriy Tarasov
  • 1,949
  • 20
  • 37
4
votes
0 answers

Problems injecting a custom service using Roboguice

I just started playing around with Roboguice and I'm trying to inject one of my services in an activity or fragment. What happens is that my service is just instantiated and injected as a POJO and no lifecycle methods are called which makes me…
user1573546
  • 523
  • 5
  • 13
4
votes
2 answers

Roboguice 2.0 injecting application into POJO

I'm newbe in Roboguice, please help. I have an application calss MyApplication in which in onCreate method i initialize some data. Also i have a POJO with buisiness logic which i want to use in my MainActivity (See code snippets below). I need to…
Dmitriy Tarasov
  • 1,949
  • 20
  • 37
4
votes
2 answers

How do I configure my ivy.xml for guice 3.0 to use the no aop jar?

The ivy file for Guice 3.0 includes a guice-3.0-no_aop.jar. Since I am creating an Android application I would like to configure my ivy file to make use of that jar instead of the guice-3.0.jar.
ahsteele
  • 26,243
  • 28
  • 134
  • 248
4
votes
1 answer

Releasing ORMLite helper on @Singleton

I have a @Singleton class where I've injected an instance of OrmLiteSqliteOpenHelper. Do I actually ever need to call the OpenHelperManager.releaseHelper()? In case I do, where and how should it be done as the class doesn't extend any Android base…
hleinone
  • 4,470
  • 4
  • 35
  • 49
4
votes
3 answers

Roboguice and mocks: How to have roboguice inject a mock service when testing but use the REAL otherwise?

Just got my feet wet with roboguice, i like it! I have quite a lot of methods that depend on a DB and LocationManger etc hence when i am testing these it uses the real objects, i would like to mock these objects so that when i am testing i don't…
Martin
  • 23,844
  • 55
  • 201
  • 327
3
votes
1 answer

Using RoboGuice context injection with an AbstractThreadedSyncAdapter

I am using RoboGuice 2.0b4 to wire up my Android application, which makes use of a SyncAdapter (derived from AbstractThreadedSyncAdapter) hosted in a regular service: @ContextSingleton public class SyncAdapter extends AbstractThreadedSyncAdapter { …
Thilo-Alexander Ginkel
  • 6,898
  • 10
  • 45
  • 58
3
votes
1 answer

replace singleton instance in a running roboguice application

I have an android application using roboguice as a dependency injection framework. There are several singleton services defined, which are used in the application as well in activities. My problem is that we have a robotium test, which testing the…
alosdev
  • 384
  • 2
  • 14
3
votes
1 answer

Roboguice, AndroidAnnotations and events between threads

When RoboGuice fires Event, where will my event callback be executed, in which thread? For example, I have an activity which has do(@Observes OnUpdateUiEvent e). I also have a background thread which fires new OnUpdateUiEvent("data"). So, my do()…
naixx
  • 1,176
  • 11
  • 17
3
votes
2 answers

Does RoboGuice re-instantiate previously existing objects when onCreate() is called

My Activity is injected with a number of objects that are initialized before onCreate is called for the first time. When my Activity finishes by invoking the finish method, it passes through onDestroy before returning to the main "OS desktop"…
DJ180
  • 18,724
  • 21
  • 66
  • 117
3
votes
3 answers

How do you inject impl of some interface in an Android Activity using Guice

I'm using Guice 3.0 on Android to do some DI. I have public interface APIClient { } and public class DefaultAPIClient implements APIClient { } What I did was try to bootstrap Guice in my MyApplication class giving it a module that has one…
Adrian Rodriguez
  • 3,232
  • 2
  • 24
  • 34