I see one situation where you cannot use the standard method of passing parameters through Intent : when you create an action that will be launched by another application (say, the edit action is a Tasker plugin) and therefore do not have control over the Intent that will trigger your activity .
It is possible to create an Activity that takes parameters in its constructor. However, the trick with using it is not to use it directly, but to use a derived class with a standard constructor that calls super() with the corresponding arguments as such:
class BaseActivity extends Activity { public BaseActivity(String param1, int param2) {
Naturally, if you need to generate parameters to switch to BaseActivity() , you can simply replace the encoded values ββwith function calls.
source share