Good,
So, I am doing an interface element library project. There are some actions in the library based on ActionBarSherlock , which is backward compatible for the action bar in android. In these actions, I would like to have a button in the action panel that will bring the user home no matter what activity they use in the library project.
Some terminology. "Library" refers to the Android UI library project I'm working on. βApplicationβ refers to any client that a developer can use with the library included.
Usually, when you do an operation and you want to call another, you would do something like this.
intent = new Intent(this, WhateverMyActivityName.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);
Simple enough. But here is a difficult bit. Android libraries practically don't know which application uses them. Thus, "WhateverMyActivityName.class" is useless, as there is no way to predict what a development application will call by its actions.
I need to replace
intent = new Intent(this, WhateverMyActivityName.class);
with something like this
intent = new Intent(this, getApplication().MainActivity().getClass());
or perhaps use some kind of intent action that will trigger the main activity in the application (Intent.ACTION_MAIN or Intent.CATEGORY_LAUNCHER)
So, briefly: how to get the main activity of applications from the library project?
source share