如何检索Intent请求的活动

Blu*_*ell 17 android class instanceof android-intent

说我有这样的意图:

 Intent intent = new Intent(context, MyActivity.class);
Run Code Online (Sandbox Code Playgroud)

然后我想要一个将为以下内容返回true的方法:

 boolean found = intent.getSomeMethodToRetrieveActivity() instanceof MyActivity;
Run Code Online (Sandbox Code Playgroud)

基本上有没有办法找出意图解决的活动?

有任何想法吗?

编辑

仔细阅读src我可以看到我可以得到这样的类名:

 intent.getComponent().getClassName()
Run Code Online (Sandbox Code Playgroud)

这将返回" com.my.package.MyActivity",这是关闭,但我想使用instanceof

Blu*_*ell 32

我最后equals()在我的问题中使用了:

 intent.getComponent().getClassName()
Run Code Online (Sandbox Code Playgroud)