I have an alarm manager and I check with my server every 30 minutes for new data, i want to measure battery usage of this specific task or another question how to measure battery usage of running each service and class in my application?
Whether checking every 30 minutes or every 2 hours, there shouldn't be a difference. (I'm assuming that the processing you are doing when you check is small.) Checking too often is a problem with regards to battery drain but only in situations where the interval between checks is <1 sec.
So if your question is, "What is the best interval to use?" then 30 minutes shouldn't be a problem.
If your question is, "I'm having a problem with battery drain and need to find out where it is," then this becomes a profiling question. And it gets much more complicated, especially when you are trying to view things from a class or even a light weight process (e.g. a thread) standpoint. You can do profiling at a class or thread level but it becomes very complicated unless you have hardware with special registers for recording power, current or voltage information.
If you only need to profile at a process level, there are plenty of good tools. A simple web search will suffice. Power consumption is closely tied to CPU usage. If you reduce CPU usage, say by making your program faster, you will likely also reduce energy consumption (i.e. power).