After Air India, lots of people ask me what measures are in place to detect this risk.
The answer is: none really. You could detect it in a new applicant with a mental health history (except in Germany – see the Germanwings thread – unless it was obvious) but you cannot detect it in a pilot who has been in the system for some years.
In my CAA medical they ask me questions like whether I feel depressed etc etc but no intelligent person wishing to get or keep their medical will answer those the wrong way.
Is there some method?
IMHO they are asking the wrong question.
The real issue is how to prevent suicides from happening on board airplanes, particularly airliners, as part of flight ops.
The FAA have clear rules about pilots being alone in the flight deck, particularly since the introduction of the locking mechanisms post 9-11. For a while those rules (always two people on the FD at all times) were also introduced in Europe and other parts of the world, but were cancelled again. IMHO this was a mistake, as a recent case shows where once again a pilot was temporarily locked out of a flight deck with the 2nd pilot being incapacitated.
It appears that there are now moves to furnish cockpits with internal toilets in order to exclude the possibility of unintentional lock outs.
The other thing is that if pilots DO seek help, then they have to be taken seriously. The sad case of the LAM 470 crash in Botswana, where the Captain had actually asked to be relieved of flight duty but was pushed to continue flying, shows clearly the necessity of taking mental health seriously.
Following the public outcries and often premature allegations of alleged pilot suicides, there has been a lot of people who demanded stricter psychological screening of pilots. Most of these demands have been rejected mainly because, as you say correctly, it is very unlikely that people who are harboring thoughts like this would reveal them to AME’s or psychologists out of fear of loosing their medical, which IMHO is quite real in today’s CYA society. Hence, my personal take is that prevention should focus on flight operations rather than subjecting pilots to more psychological stress, which in turn might have the opposite effect.
Mooney_Driver wrote:
The FAA have clear rules about pilots being alone in the flight deck,
Indeed. The airline pilots in our club were aghast at the recent Lufthansa episode.
However, wrt mental health, the issue is that many pilots who experience some form of mental health issue don’t come forward and seek help, as it mostly means losing their medical. In FAA-land counseling is fine, but medication is not. A good friend just regained his medical after three years and endless evaluations and to-and-fro with the aeromedical department of the FAA. The good news, however, is that the FAA is starting to recognize that this approach only makes matter worse. There are several proposals out there, to change the how mental health issues are handled in an aviation context.
Peter wrote:
In my CAA medical they ask me questions like whether I feel depressed etc etc but no intelligent person wishing to get or keep their medical will answer those the wrong way.
Yes and no. With depression (with anything, really) the more you screen for it the more you pick it up. With legit depression many times the person afflicted can actually be quite relieved about being asked about depression and suicidality. And for the most part generally healthy pilots won’t have contact with the medical system other than through aeromedical examiners so the questions do make sense.
No intelligent person would pilot a plane into a mountain or shut off fuel flow to the engines right after takeoff. But the brain works differently when depressed so asking about depression is reasonable.
I am sure a non-pilot with depression is happy to talk about it, but not a pilot talking to an AME, knowing that his flying days are terminated the same day. Any AME will tell you how everybody who walks through the door tells him about how fit he is 
Perhaps the answer is that it is not possible, and the only way is to prevent a pilot being alone in the cockpit. But even that will never completely work because there are multiple ways to rapidly crash an airliner when close to the ground. OTOH most of those will result in that pilot being clearly blamed. Flipping fuel switches and asking the other one why he did it avoids blame being attached.
Peter wrote:
Perhaps the answer is that it is not possible, and the only way is to prevent a pilot being alone in the cockpit. But even that will never completely work because there are multiple ways to rapidly crash an airliner when close to the ground.
What this does prevent however is to have crew locked out after a toilet break or so. All the FA in the cockpit needs to be able to do is to open the door.
Also there is another psychological thing about it. Suicide is quite a personal thing and having another person there might actually stop a person from even trying.
But as we have seen recently, incapacitation can be a much more likely reason why a pilot may not open the door. Again, the 2nd person in there would have been very useful in this incident.
Peter wrote:
The answer is: none really.
No, none really. If there was, the airlines would already make use of it.
Because you won’t notice it, if you don’t get really close to a person, the “Deutsche Depressionshilfe und Suizidprävention” once made the following poster as hangouts e.g. for subway stations which I saw when it was out, just remembered it:

It’s in German, but I think you can get the message.
(there are two text portions in the image. The lower one says “Steffen suffers from a depression”. The upper one is barely visible. It says “this is Steffen”)
Badly designed, but I get it. Steffen obviously is the guy laughing and NOT the sad looking man in the foreground.
I think the “bad” design is on purpose, for the “surprise” effect. I found the poster well made, because when I saw it it produced exactly the intended reaction. You have to look a bit closer to recognise its message.