Мое решение для этой проблемы было
В методах добавления фрагмента:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...
guideMapFragment = (SupportMapFragment)a.getSupportFragmentManager().findFragmentById(R.id.guideMap);
guideMap = guideMapFragment.getMap();
...
}
@Override
public void onDestroyView() {
SherlockFragmentActivity a = getSherlockActivity();
if (a != null && guideMapFragment != null) {
try {
Log.i(LOGTAG, "Removing map fragment");
a.getSupportFragmentManager().beginTransaction().remove(guideMapFragment).commit();
guideMapFragment = null;
} catch(IllegalStateException e) {
Log.i(LOGTAG, "IllegalStateException on exit");
}
}
super.onDestroyView();
}
Может быть плохо, но не удалось найти ничего лучшего.
Вот как я реализовал Session в своем проекте ASP .NET CORE:
Создайте фильтр SessionTimeout:
public class SessionTimeout : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext context)
{
if (context.HttpContext.Session == null ||!context.HttpContext.Session.TryGetValue("UserID", out byte[] val))
{
context.Result =
new RedirectToRouteResult(new RouteValueDictionary(new
{
controller = "Pages",
action = "SessionTimeout"
}));
}
base.OnActionExecuting(context);
}
}
Зарегистрируйте этот фильтр в файле Startup.cs:
В вашем методе ConfigureServices:
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(10);
});
В вашем Configure добавьте:
app.UseSession();
И, наконец, украсьте свой класс / метод с помощью фильтра, например:
[SessionTimeout]
public class DashboardController : Controller
[ 1111] Чтобы уничтожить ваш сеанс на основе события выхода из вашего просмотра:
public IActionResult Logout()
{
HttpContext.Session.Clear();
return RedirectToAction("Login", new { controller = "Pages" });
}