Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.Intent; public class Main { /** * stop the running service. */ public static boolean stopRunningService(Context context, String className) { Intent serviceIntent = null; boolean result = false; try { serviceIntent = new Intent(context, Class.forName(className)); if (serviceIntent != null) { result = context.stopService(serviceIntent); } } catch (Exception e) { e.printStackTrace(); } return result; } }