Android starting a Modal Activity
In my application, I need to implement password validation. I would like to create a modal activity which cannot be escaped to go inside the app unless password is provided. The tricky part is that there are other threads running in the app, which connects to server and starts various other activities on successful connection. This situation causes other activities to start even when the user is still on the password validation screen.
I am looking for a solution where within my applic开发者_运维问答ation Validation activity is a modal activity and hence always reside on top until finished programmatically.
Is there a Intent flag or some logic which will allow this password validation activity to stay on top always. I am open to analyze any security framework available which will allow me to do this.
As you have menationed first you are connecting to server. once the connection is successful you are creating some threads for different purpose. All these have no dependency with password validation still now. I think if your server connection will be established only after getting password from user. also if you mantain a flag regarding userauthentication. if user is authenticated and server is connected then only start those service. You need startActivityForResult
concept. Click here
Can you try with this logic?
Thanks Deepak
You should implement the password validation activity as a Sub Activity, and in the onActivityResult, only proceed if the password validation completes successfully (Call up other activities or anything else on a successful password validation), if it returns RESULT_CANCELED, make sure to finish of the calling activity.
This will make sure unless password validation is successful, nothing else happens
精彩评论