Activity对外提供方法,面向对象思想

1
2
3
4
5
6
7
8
9
10
11
12
public static void goTo(Context context) {
Logger.i(TAG, "Go to the main activity");
Intent intent = new Intent(context, MainActivity.class);
if (context instanceof Activity) {
context.startActivity(intent);
} else {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
}