开发者

Why there isn't a simpler way to stop an activity from another?

I know there are many topics about this, and I understand (or at least I think I do) the Activity lifecycle. I know the Activity itself should handle its lifecycle, including the process of stopping the Activity.

But, in some cases, this is just not practical, for example, if you have a controller, to manage your interface, and maybe receiving I/O results.

So, wouldn't be nice just to send some Intent with an action like a ACTION_STOP_REQUEST, and let the Acti开发者_开发技巧vity handle it?


So, wouldn't be nice just to send some Intent with an action like a WHATEVER, and let the Activity handle it?

AFAIK, that's what BroadcastReceivers are for.


As Cristian suggested, use BroadcastReceiver

You could include private BroadcastReceivers in each Activity that you would want to respond to the ACTION_STOP_REQUEST and have them call finish() in onReceive()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜