When you repeatedly open an Activity, the following error occurs:
E/StrictMode: class br.com.teccity.cardapiosduchef.empresa.EmpresaActivity; instances=2; limit=1 android.os.StrictMode$InstanceCountViolation: class br.com.teccity.cardapiosduchef.empresa.EmpresaActivity; instances=2; limit=1 at android.os.StrictMode.setClassInstanceLimit(StrictMode.java:1) W/System.err: StrictMode VmPolicy violation with POLICY_DEATH; shutting down.
Looking for a solution through the internet forums, I found the following example:
@Override
protected void onCreate(Bundle savedInstanceState) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectCustomSlowCalls() // API level 11, to use with StrictMode.noteSlowCode
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.penaltyFlashScreen() // API level 11
.build());
try {
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects() // API level 11
.setClassInstanceLimit(Class.forName("com.apress.proandroid.SomeClass"), 100)
.penaltyLog()
.build());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
super.onCreate(savedInstanceState);
But that also did not solve the problem.