How to remove(unregister) registered instance from Unity mapping?

I had the same problem and just removed the registrations of the ContainerControlledLifetimeManager from my Container: foreach (var registration in container.Registrations .Where(p => p.RegisteredType == typeof(object) && p.Name == name && p.LifetimeManager.Type == typeof(ContainerControlledLifetimeManager))) { registration.LifetimeManager.RemoveValue(); }

Using onCreate vs. onRestoreInstanceState

onRestoreInstanceState This method is called after onStart() when the activity is being re-initialized from a previously saved state, given here in savedInstanceState. Most implementations will simply use onCreate(Bundle) to restore their state, but it is sometimes convenient to do it here after all of the initialization has been done or to allow subclasses to decide …

Read more

Java: newInstance of class that has no default constructor

Call Class.getConstructor() and then Constructor.newInstance() passing in the appropriate arguments. Sample code: import java.lang.reflect.*; public class Test { public Test(int x) { System.out.println(“Constuctor called! x = ” + x); } // Don’t just declare “throws Exception” in real code! public static void main(String[] args) throws Exception { Class<Test> clazz = Test.class; Constructor<Test> ctor = clazz.getConstructor(int.class); …

Read more