How can I create an Intent from class in a package to a class from different package?
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);
and his code is in class which is in p开发者_运维知识库ackage : com.example.anotherone
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.
Thanks anyway!
Make sure you are importing the class you want
import com.example.anotherone.Classname;
and pass Classname.class in your intent,
Intent intent = new Intent(view.getContext(), Classname.class);
And that your Manifest is updated with the correct name for the activity (com.example.anotherone.Classname).
If you want to start an activity from another application, you can do it by specifying the intent action. When you define the activity you want to start in its application Manifest file, you can set it's <action/>
tag inside <intent-filter/>
to whatever action you want. Then to start this activity from another application call
Intent intent = new Intent("your-action-name");
startActivity(intent);
Your application will be the only to answer on this action request and it will open. Hope this helps.
1.At first import the class you want.
2.pass the class name with intent.
For example:
import package.otherclassname.yourclassname;
Intent intent=new Intent(view.getContext(),yourclassname.class);
精彩评论