I am trying to detect cycles with BFS algoritm in a directed graph. My main idea to detect the cycles is: since BFS visites each node (and edge) only once, if I encounter an already visited node again; it causes a cycle. However, my code sometimes finds the cycle, sometimes not.

The problem with your implementation is that it assumes the graph is connected. But the reality is you may be deal with a graph that has two connected portion, so that if you start with v you will never get into the other portion. To solve your problem, you need to find a way to identify subgraphs that may not be connected. You may find some suggestions on wikipedia http://en.wikipedia.org/wiki/Topological_sorting#Algorithms where they talk about

S ← Set of all nodes with no incoming edges

EDIT:

actually an easy change you can make is instead of enqueueing v, enqueue all the nodes Dijkstra style. That way you should always find your cycle. Also where are you getting t from since it's not part of the method signature?

The algorithm you have given might report the existence of a cycle even if no cycle exists.
In line number 12, you we have u adjacent to t. A parent of t in BFS tree also lies in it's adjacency list.
So, line 13 might return false even when no cycle exist because a parent of t is marked and is a part of t's adjacency list.

So, I think this algorithm will report a cycle if it is present but it might also report a cycle even when there is none.