I'm not sure if it's possible to inject an object with RoboGuice while passing a parameter to its constructor (and this is certainly not encouraged). You might want to consider just changing whatever method you call on that object that writes to the file system to take in that String
parameter. If you don't like that option, you can just have a public method to set that parameter before calling the write function.
Ex:
@Inject
private MyClass myClass;
public void onCreate(Bundle savedInstanceState) {
super.onCreate();
myClass.setFileName("somefile.txt");
myClass.writeToFile();
}
Or
@Inject
private MyClass myClass;
public void onCreate(Bundle savedInstanceState) {
super.onCreate();
myClass.writeToFile("somefile.txt");
}
EDIT:
So after doing some research I'm taking back my statement about this not being encouraged. From the examples I've seen, your code looks to be be mostly correct. This Link provided the most complete example I could find. It seems that there are two options if you want to inject a String into the constructor. you can set it up in you app config bindings (which essentially creates a singleton that you probably don't want). The second option is to create a Provide (similar to Factory) and use that provider. Both of these options are outlined in the article above.