异常(栈里必须有activity的flag标识):
05-02 08:43:36.173: E/AndroidRuntime(3328): android.util.AndroidRuntimeException:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag.
Is this really what you want?
解决办法:
Intent intent = new Intent(getApplicationContext(), BackgroundActivity.class);
// 如果当前activity关闭了,现在栈里没有了activity,由服务中去开启一个新的activity时需要给其创建一个新的标识
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);