如何从一个包中的类创建一个意图到另一个包中的类的Intent? [英] How can I create an Intent from class in a package to a class from different package?

查看:69
本文介绍了如何从一个包中的类创建一个意图到另一个包中的类的Intent?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定如何解释这一点,希望您理解我.这是问题所在:

Not sure how to explain this,hope you understand me.. Here is the problem :

我的应用程序中有一些软件包,我正在这样做:

I have a few packages in my app and I'm doing this :

Intent intent = new Intent(view.getContext(), com.example.app.Lol.class); 
startActivity(intent);

并且他的代码在类中,该类在包中:com.example.anotherone

and his code is in class which is in package : com.example.anotherone

正如我所见,这是不可能的,这就是为什么我要问..我必须做什么,所以我能够像上面的示例一样创建一个Intent.

It's not possible as I saw, that's why I'm asking..what I have to do, so I can be able to create an Intent like the example above.

还是谢谢!

推荐答案

确保要导入所需的类

import com.example.anotherone.Classname;

并按您的意图传递Classname.class,

and pass Classname.class in your intent,

Intent intent = new Intent(view.getContext(), Classname.class);

您的清单将使用活动的正确名称(com.example.anotherone.Classname)进行更新.

And that your Manifest is updated with the correct name for the activity (com.example.anotherone.Classname).

这篇关于如何从一个包中的类创建一个意图到另一个包中的类的Intent?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆