2

Background

I'm planning to implement a password reset function in my application. After some research, I've evaluated this approach to fit my needs:

  1. User enters a "Reset Password" Activity where he enters a pre-registered email to be send a reset link.
  2. The system has a table password_change_requests with the columns ID, Time and UserID. When the user presses the "send" button to reset the password, a record is created in the table. The Time column contains the time when the user pressed the "Forgot Password" button. The ID is a string. A long random string is created and then hashed like a password. This hash is then used as the 'ID' in the table.
  3. The system sends an email to the user which contains a link in it. The link also contains the original ID string (before the hashing).
  4. When the user clicks the link in the email, he is moved to the application in question. The app retrieves the ID from the URL, hashes it again, and checks against the table. If such a record is there and is no more than, say, 24 hours old, the user is presented with the prompt to enter a new password.
  5. The user enters a new password, hits OK.

This approach was inspired by the answer to this question by Vilx-.

The difficulties

At first glance, the above presented approach seemed to be easy enough to implement. But I've ran into some headaches. Step (1) and (2) are easily implemented. When I had a closer look step (3) and (4) my initial thought was to send some kind of Intent with the email, since that's the usual way to launch applications. But since the "source" of the intent would be HTML code at best, I'm not quite sure if that will work.

Questions

  1. How can I launch my specific android application from an email (say an HTML anchor tag) in the users inbox?
  2. How do I pass on the data (the ID string) to my application via the email?

And if this is not possible, is there an alternative way to solve the above approach?

Community
  • 1
  • 1
Marcus
  • 6,697
  • 11
  • 46
  • 89

1 Answers1

3

How can I launch my specific android application from an email (say an HTML anchor tag) in the users inbox?

There is no guaranteed way to do this. Email applications are not obligated to pay a lick of attention to you.

You are welcome to have an activity in your app, with an <intent-filter> that advertises that you wish to respond to certain URLs or URL prefixes, such as http://marcussystem.com/hey/lets/run/the/app. In theory, when the user clicks on a link in an email that points to a matching URL, your app will be included in the chooser (along with Web browsers) for the user to select.

Or, you are welcome to craft a URL using the intent scheme that opens one of your activities. The email client may not recognize that as a valid URL, but it would bypass the chooser.

But, again, there is no requirement for any email client to support what you want. This goes double for users who happen to view their email in a mobile Web browser.

How do I pass on the data (the ID string) to my application via the email?

In the http URL case, have it be part of the URL itself, preferably in the path: http://marcussystem.com/hey/lets/run/the/app/and/here/is/the/ID/..., where ... is your ID (assuming that it is purely URL path-friendly characters).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Using `` seems like one valid approach, even though it has it's drawbacks as pointed out. Another thought was that I could have the URL pointing to a web server of mine, which could snatch the data parameters and run a script to launch the app. This might eliminate the "chooser problem". Are there any server-side languages that support this that you know of? – Marcus Aug 04 '15 at 16:13
  • @Marcus: "and run a script to launch the app" -- that's not really possible. At best, you could say that the Web server returns a Web page to the device's browser, where that page contains a link designed to run your app. – CommonsWare Aug 04 '15 at 16:47
  • That's too bad. I'll go with the intent filter by the current looks of it. As always, your answer is most appreciated, thanks! – Marcus Aug 04 '15 at 17:01