Java tutorial
//package com.java2s; import android.content.Context; import android.content.Intent; public class Main { public static boolean stopService(Context context, String className) { try { Intent intent = new Intent(context, Class.forName(className)); return context.stopService(intent); } catch (Exception e) { e.printStackTrace(); return false; } } }