0
我有不同的活动,其中catch {}块主要应该做同样的事情,例如。显示Toast消息,完成()应用程序或其他内容。所以我让一个静态类来处理它们。它工作到现在,但我想知道它是保存。将活动对象传递给静态类
要完成一个活动,我必须调用Activity类中的finish(),所以我必须通过它。
我犯了这样的静态函数:
public static void handleException(Exception e, Context c, Activity a) {
// handle the exception, for example if there is an authorisation error:
a.finish();
}
在catch {}块我做到以下几点:(在这种情况下活动LoginActivity)
ExceptionHandler.handleException(e, _context, (Activity) LoginActivity.this);
这是合适的?或者这会导致内存泄漏?