android - How to call unregisterReceiver on a BroadCastReceiver -


I have some such activities that are extending from a custom square that I wrote that in return Activity < / Code>. I named this class as loginfinder activity and override the onCreate function on it

  Private Broadcast Receiver Filler Receiver = tap; Public static final string ACTION_FINISH_LOGIN = "ACTION_FINISH_LOGIN"; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); Log D. ("Login finisher activity", "ont () called."); FinishReceiver = New Finnish Receiver (); Register Receiver (full receiver, new intent filter (ACTION_FINISH_LOGIN)); }  

Now the number of activities that have been extended to login-seeking activity is for those people, whenever I click on the system's back button. That is, I am on a welcome activity and I want to proceed in sign-up activities. But when I sign in or sign up, I work on NavigationActivity > Activity increases, that means it needs to be closed, whatever came from the activity, it did not go back. I was able to do that if I deleted the onPause and onResume function from LoginFinisherActivity I My FinishReceiver The code for the following is as follows:

  The personal finishing range expands the broadcaster receiver {FinishReceiver} {@ Override Reverse on Public Zero (Reference Reference, Intent of Intent) {If (intent. GetAction (). (ACTION_FINISH_LOGIN)) {end ();  

Thank you for your help in advance.

Edit: LoginFinisherActivity overrindon onPause and onResume Pre> @override at protected voidPause () {Log.d ("LoginFinisherActivity", "onpaused () called."); Super.onPause (); If (Finnish receiver! = Null) {unregistered receiver (Finnish receiver); Finish receiver = faucet; }} @ Override Resume on Reserved Zero (Reference Reference, Intent of Intent) {Log D. ("Login finisher activity", "honor () called."); Super.onResume (); If (intent.getAction (.) Equals (ACTION_FINISH_LOGIN)) {end (); } Other {if (Finnish Receiver == blank) Register Receiver (Finnish receiver, new intent filter (ACTION_FINISH_LOGIN)); Suppose that you want to end your activities on successful login / register, I think that the best way would be to use startActivityForResult (intent, int REQUEST_CODE) instead of dealing with it more intensively, making the flow more complex gives.

You can also use Android. Support.v4.content.IntentCompatIntentCompat.MakeRestartActivityTask (...) If you want to end the last stack of activities.

Hope it helps.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -