void android.content.Context.startActivity(Intent intent)
Launch a new activity. You will not receive any information about when the activity exits.
Note that if this method is being called from outside of an android.app.Activity Context, then the Intent must include the Intent.FLAG_ACTIVITY_NEW_TASK launch flag. This is because, without being started from an existing Activity, there is no existing task in which to place the new activity and thus it needs to be placed in its own separate task.
This method throws ActivityNotFoundException if there was no Activity found to run the given Intent.
Parameters:
intent The description of the activity to start.
Throws:
ActivityNotFoundException
See Also:
PackageManager.resolveActivity
Launch a new activity. You will not receive any information about when the activity exits.
Note that if this method is being called from outside of an android.app.Activity Context, then the Intent must include the Intent.FLAG_ACTIVITY_NEW_TASK launch flag. This is because, without being started from an existing Activity, there is no existing task in which to place the new activity and thus it needs to be placed in its own separate task.
This method throws ActivityNotFoundException if there was no Activity found to run the given Intent.
Parameters:
intent The description of the activity to start.
Throws:
ActivityNotFoundException
See Also:
PackageManager.resolveActivity
本文详细介绍了如何使用void android.content.Context.startActivity(Intent intent)方法启动一个新的Activity。需要注意的是,如果此方法不是从Activity上下文中调用,则必须在Intent中包含Intent.FLAG_ACTIVITY_NEW_TASK标志。此外,文章还提到了如果找不到匹配的Activity来运行给定Intent时会抛出ActivityNotFoundException。
594

被折叠的 条评论
为什么被折叠?



