ADD: Activities.startActivity().

This commit is contained in:
Oasis 2016-08-18 23:28:45 +08:00
parent 3bd20c3e22
commit 2ed9ab582c

View File

@ -5,6 +5,7 @@ import android.app.Application;
import android.app.Service;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.support.annotation.Nullable;
/**
@ -22,4 +23,10 @@ public class Activities {
if (base_context == context) return null;
return findActivityFrom(base_context);
}
public static void startActivity(final Context context, final Intent intent) {
final Activity activity = findActivityFrom(context);
if (activity != null) activity.startActivity(intent);
else context.startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
}
}