It’s practically impossible (-20 penalty) to hide while attacking, running or charging.
So you can remain hidden while making a spring attack, but the DC to spot you is not going to be very high. If you still manage to win the opposed roll, your target will be denied its Dexterity bonus to AC and will have an additional -2 penalty because you are effectively invisible.
From Skip Williams' column:
If a foe you cannot see hits you with
a melee attack and is adjacent to you
at the time, you know the foe's
location. For this reason, smart foes
move right after they attack; even a
foe that has made a full attack can
move after attacking by taking 5-foot
step (provided it has not already
moved during its turn).
When an unseen foe hits you with a
melee attack from more than 5 feet
away, you know the general direction
from which the attack came and that
the attack came from more than 5 feet
away, but you do not know the
attacker's location.
That is the main reason to spring attack: you need to move after attacking, even if invisible, otherwise your target will know your location. If your target has failed its spot check, you still have total concealment (50% miss chance).
Stealth is fun.
Shadowdancer may be one of the most popular Prestige Classes in 3.5e, and that is solely due to the Hide in Plain Sight feat. Many players enjoy the thought of sneaking invisibly to the enemy and rolling insane backstab/sneak attack damage.
Unfortunately, stealth in D&D is not always that fun.
Now, the backstab part is awesome, and that's why most stealth players enjoy it. The problem is that the D&D mechanics as they are played out in most campaigns do not make much of stealth beyond a canned skill challenge. By looking at some good stealth games for the computer, such as Dishonored or Assassin's Creed, we can take some tips and add them to our campaigns.
Objectives
This is the biggest change that a DM has to foster in his campaign. As mentioned before, the objective of stealth is almost always just to get in some extra sneak attack damage. Stealth gets boring when, in the end, it's only about combat. There is nothing wrong with sneak attacks, of course. Some of the most memorable moments in my campaigns have been sneak attacks (double crit + 4x backstab damage FTW?), but stealth needs variety.
The purpose of stealth is to remain undetected. Let stealth be a tool for defeating encounters. If the players successfully sneak around an entire group of hobgoblins, give them full XP as if they had beaten the fight. And don't just stop there. If you want great stealth encounters, turn it into a real challenge like Dishonored does. Make enemies move around somewhat unpredictably. Have your players use distractions, or find opportunities to pick off the enemy one at a time. Give them bonus XP or a better reputation for being able to complete encounters without bloodshed, similar to Dishonored. Also like Dishonored, make a few combat encounters really dangerous if you rush right into them, and be sure to make that fairly clear through in-game information.
Environment
The world is bigger than a grid. Description helps. Open up the terrain for movement, like Assassin's Creed. Let them sneak past the royal guard by balancing across the rafters of the great hall or by sneaking over the rooftops to bypass the thugs waiting for them in the street. Think in 3D even though the grid is 2D.
Light is a huge factor for stealth in a lot of games, such as Amnesia: The Dark Descent. It ought to be very important in D&D as well, what with all the torches, lanterns, and magical lights often found in its environments. Have players make strategic use of light. One campaign, my players doused a torch while the guard was on the other side of the building so that when he came back, he couldn't see them sneaking inside. Unfortunately, the sudden lack of light alarmed him, which leads to another point:
The Chase Sequence
The way you describe the ninja character as cycling through backstab -> run -> hide -> backstab definitely confirms this as a bad pattern of stealth. One of the biggest flaws of the first Assassin's Creed game was how you could stab someone, run like heck, hide on a bench right around the corner, then go back and stab someone else. Rinse. Repeat. Worst of all, until they introduced notoriety in later games, it seemed like everyone forgot what you did.
Dishonored is a much better example of how to do detection and chase effectively. On the very first detection, the enemy is immediately alert and aware of the fact that you do not belong here. Hostility begins right away, and the chase is brutal. In a chase, NPCs do not let you get away unless you do something really daring. In the TV Show Burn Notice, the main character remarks during a narrative in a chase sequence that the only way to escape a chase is to do something that the people chasing you won't do -- like jumping off a roof.
And even if you get away, the NPCs should not just "forget" about you. They should be on high alert until you die or they are convinced that you have been driven off. Enemies on high alert for a stealth PC should not be easy to catch off-guard. In addition, they should not be splitting up alone if they are even reasonably intelligent.
Have NPCs adopt tactics like the PCs tend to act when encountering stealthy foes.
All Alone
"But I'm the only stealth character on the team!"
This is roughly the ninja player's position, I take it. I've been there. Fortunately, you don't have to be reliant on stab-and-run to be useful. A number of the former tips are intended for stealth-based encounters, but here's what a stealth PC has gotta do to have fun with stealth while your allies are kickin' down doors in the name of Tempus:
1: Wait for the encounter to get started. Be out of sight on the periphery.
2: Sneak up to a squishy target.
3: Stab.
4: ???
5: Profit.
An ultra-stealthy character is ideal for taking out priority targets. Then, using other skills, such as acrobatic-type skills, make a daring escape. Not just running away by pure movement points, but dodging between pillars, leaping onto ledges, or tumbling past enemies to rejoin your allies.
Stealth should get you into the fray. Speed and tricks should get you out.
First, this adds variety to your actions as a stealthy character.
Second, it should be hard to lose detection when enemies are tracking your movements so closely.
Beyond combat, a stealthy character can still be a great asset. Perhaps you can open a gate while the party is fighting. Maybe you can sneak into a camp and rescue a prisoner while the party is attacking from the opposite side. Generally, you should avoid going too lone wolf unless your party wants you to do so, because that's dangerous and slows down the game for others. Performing a stealth mission while the party fights a battle has been the best possible scenario in campaigns I have played. It keeps everyone busy, provides a distraction, and lets your group benefit from stealth simultaneously.
TL;DR version: Stealth should be more than dice rolls. It needs to interact with the environment and the intelligence of the NPCs involved. It should be rewarding, fast-paced, and require cleverness more than just sneakiness. When done right, it should give the party big advantages as a whole.
Best Answer
Immediately after whatever caused them to lose the condition allowing them to Hide. That is sometimes "immediately", and sometimes after an action. Lets look at some examples:
Hide
Say you're using Hide to be hidden, because you have Cover or Concealment. It's daytime, or another source of full illumination. Here's the relevant part of Hide (emphasis mine):
If you walk out of cover/concealment and into the open where you can be seen, you're seen. Period. This happens immediately, as per Spot:
Vision in D&D is omnidirectional and immediate. A spot check in daylight has DC 0, so it's basically impossible to fail. You can't use Hide because you don't have cover or concealment.
What does that mean for Sneak Attack? You can't use it. You can't use it by walking out, you can't use it in a charge, or any other way. Unless you can attack from cover/concealment, you can't do this with Hide.
Note that you can Snipe, from range:
The reason why this works is that you can attack from behind cover at range, so the condition to attack while hidden (and then hide again) exists. They're "aware" of you, but they are denied their dexterity bonus to AC because they can't see you to defend against you (as you're hidden). In this case, you can Sneak Attack.
Hide in Plain Sight
Depending on how you get it, Hide in Plain Sight has some conditions. If you meet those, you can use Hide even if you don't have cover/concealment and often times if people are watching you. This makes Hide work far more effectively - You can hide, move up, and attack. Your first attack will deny them dex to AC (and thus enable Sneak Attack) if your hide check succeeds against their spot.
After the first attack, you'd have to Hide again (at a -20 penalty for attacking) to remain hidden. If you don't, any subsequent attack that round is not considered hidden. Thus, they get their dex bonus to AC and you can not Sneak Attack.
Note that using Hide after attacking is in most cases a move action, so your DM will probably not allow you to full attack while making Hide rolls after every single attack to remain hidden.
Invisibility
You can Sneak Attack with Invisibility. That said, Invisiblity ends after the first attack you make. That means if you use a full attack, only the first attack you make gets the benefit of Invisibility. The others are made normally, with the target having his dex bonus to AC and are not Sneak Attacks. Here's the rule on that:
So once again, the "stealth status" change takes effect instantly as conditions change in combat.
Greater Invisibility does not break when you attack, and so in that case you could keep Sneak Attacking.
Now to cover your specific cases that I haven't already covered:
If the stealthed character moves before attempting a sneak attack, does the foe gain the opportunity to detect them during the movement and before the attack triggers?
Yes. That's covered by Hide and Hide in Plain Sight, above. Any time the conditions change in regards to seeing the Hiding person, they're entitled to a check.
Do they have no such opportunity if no movement is done first?
If you're already hidden (eg, you have cover and your Hide beat their Spot), if you don't break cover and they don't move to break your cover, nothing changes. You're still hidden, and can Snipe. You'll have to make a new check to stay hidden after you Snipe, as described above.
Now, they might get a move silently check if you move, even if they already failed the Spot. Listen can give them an idea of where you are, but is not enough to change the conditions for Sneak Attack (being able to hear you to the left isn't enough to change things, it just tells them what direction to search in on their turn).
If its their turn, they can make another Spot check as a move action. This applies if they failed to see you and your conditions didn't change, so they don't get a reactive check.
Is this different if the movement and attack are a single action, such as a Charge?
No, it changes nothing. In fact Charge takes its own -20 penalty to Hide.
Remember that a full attack action is a "single action" as well, but things change during it. (This is different from Pathfinder and AFAIK 4e.)
Is there any case where i can Sneak Attack for multiple attacks?
Sure. If they're Flat-Footed at the start of combat, they're denied their dex until their turn comes around. If you can attack them before that, all your attacks are Sneak Attacks.
If you flank them, you will still flank them on subsequent attacks (barring something unusual going on).
As mentioned, Greater Invisibility doesn't break when you attack, so you can keep using it.
The key takeaway here is that conditions change in response to what you're doing. It doesn't wait to take effect. If Invisibility drops after the first of your four attacks during your full round action, it drops. The other three do not get its benefit.