现象:android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
原因:不是在activity中启用的startActivity(intent)方法
解决方案:在使用startActivity(intent)方法前加上intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);即可
示例:
public void openClock(Context context)
{
Intent alarms = new Intent(AlarmClock.ACTION_SET_ALARM);
alarms.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(alarms);
}