Adamah Nour Adamah Nour - 1 year ago 69
Android Question

how to mention user in android app

I want to refer to this question , on how to implement the mention feature, but for android.

I want to know how it goes in the database specifically .

Thanks in advance <3

Answer Source

I guess the answer was already provided the old post,

Listen to the input. When the user types an @, followed by a character, make a call to an url on your server (/user/lookup/?username=joe for example) that routes to a view which looks up up users beginning with joe. Return it as json and display it in a dropdown.

To make is much simpler, you need to use @ as a keyword that is going to be used for understanding the beginning of a user name .

e.g. user types the following message

... was with @nour at NYC

in Java you can detect the @ using regular expression,

boolean foundMatch = false;
Pattern regex = Pattern.compile("\\b(?:@)\\b");
Matcher regexMatcher = regex.matcher(subjectString);
foundMatch = regexMatcher.find();

This will match if the input string has a @ keyword

Now once you get the @ keyword take all character after @ till you get a white space. In this example nour should be the result since its starts after @ and ends before a white space.

In the server part you can the the recognized name as a USER_NAME,


Of-course the username needs to the unique.

Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download