REYKJAVIK, Iceland — You meet someone, there’s chemistry, and then come the introductory questions: What’s your name? Come here often? Are you my cousin?

In Iceland, a country with a population of 320,000 where most everyone is distantly related, inadvertently kissing cousins is a real risk.

A new smartphone app is on hand to help Icelanders avoid accidental incest. The app lets users “bump” phones, and emits a warning alarm if they are closely related. “Bump the app before you bump in bed,” says the catchy slogan.

Some are hailing it as a welcome solution to a very Icelandic form of social embarrassment.

“Everyone has heard the story of going to a family event and running into a girl you hooked up with some time ago,” said Einar Magnusson, a graphic designer in Iceland’s capital, Reykjavik.

“It’s not a good feeling when you realize that girl is a second cousin. People may think it’s funny, but (the app) is a necessity.”

The Islendiga-App — “App of Icelanders” — is an idea that may only be possible in Iceland, where most of the population shares descent from a group of 9th-century Viking settlers, and where an online database holds genealogical details of almost the entire population.

The app was created by three University of Iceland software engineering students for a contest calling for “new creative uses” of the Islendingabok, or Book of Icelanders, an online database of residents and their family trees stretching back 1,200 years.

Arnar Freyr Adalsteinsson, one of the trio, said it allows any two Icelanders to see how closely related they are, simply by touching phones.

“A small but much talked about feature is the loosely translated ‘Incest Prevention Alarm’ that users can enable through the options menu which notifies the user if the person he’s bumping with is too closely related,” Adalsteinsson said.

It’s the latest twist on a long-standing passion for genealogy in Iceland, a volcanically active island in the North Atlantic that was unpopulated before Norse settlers arrived in A.D. 874. Their descendants built a small, relatively homogenous and — crucially — well-organized country, home to the world’s oldest parliament and devoted to thorough record-keeping.

“The Icelandic sagas, written about 1,000 years ago, all begin with page after page of genealogy. It was the common man documenting his own history,” said Kari Stefansson, chief executive of Icelandic biotech company deCODE Genetics, which ran the contest behind the app.

The Book of Icelanders database was developed in 1997 by deCODE and software entrepreneur Fridrik Skulason. Compiled using census data, church records, family archives and a host of other information sources, it claims to have information on 95 percent of all Icelanders who have lived in the last 300 years.

The database can be scoured online by any Icelandic citizen or legal resident. The app makes the data available to Icelanders on their mobile phones — and adds the anti-incest feature.

Currently available for Android phones, it has been downloaded almost 4,000 times since it was launched earlier this month. The creators also hope to develop an iPhone version.

Stefansson says the “bump” feature is an attention-grabbing but relatively minor aspect of an app that brings Icelanders’ love of genealogy into the 21st century.

He also hopes it won’t convey the wrong impression about Iceland.

“The Icelandic nation is not inbred,” he said. “This app is interesting. It makes the data much more available. But the idea that it will be used by young people to make sure they don’t marry their cousins is of much more interest to the press than a reflection of reality.”

It may also be of limited use. Currently the alarm only alerts users if they and their new acquaintance have a common grandparent, and most people already know who their first cousins are.

Adalsteinsson stresses that the app has other, less sexual uses.

“We added a birthday calendar to make sure you don’t forget your relatives’ birthdays,” he said.