相同class的startactivity使用Intent.FLAG_ACTIVITY_MULTIPLE_TASK

本文详细介绍了如何使用void android.content.Context.startActivity(Intent intent)方法启动一个新的Activity。需要注意的是,如果此方法不是从Activity上下文中调用,则必须在Intent中包含Intent.FLAG_ACTIVITY_NEW_TASK标志。此外,文章还提到了如果找不到匹配的Activity来运行给定Intent时会抛出ActivityNotFoundException。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值