I have an app which on startup checks for network connectivity. If there is no network connectivity, I display an error on the lines of "No data connectivity..."
It can be used as a normal app (start from app list) or can be invoked using intents from other apps.
I want to make some changes to the app so that, if its invoked via intent, I would like to behave differently which means display different error/info messages.
If we take the example of network connectivity check, I would like to display a different message than usual , if my app was invoked.
the obvious way to do this would be
if(usualFlow)
{
//display standard error
}
else
{
//display special error
}
this will get complicated as there are changes to lots of places in the code. It will also get really bad if I have something like this
if(usualFlow)
{
//display standard error
}
else if(specialflow1)
{
//display special error 1
}
else if(specialflow2)
{
//display special error 2
}
Is there a better way to do it? which pattern should i follow?
Any help is much appreciated.
Aucun commentaire:
Enregistrer un commentaire