Android examples for Camera:Camera Flash
Get Set Camera Flash Enabled Method
/******************************************************************************* * Copyright (c) 2011 MadRobot./*from ww w .j a va 2 s. c om*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * Elton Kent - initial API and implementation ******************************************************************************/ //package com.java2s; import java.lang.reflect.Method; public class Main { private static Method getSetFlashEnabledMethod(Object iHardwareService) { if (iHardwareService == null) { return null; } Class<?> proxyClass = iHardwareService.getClass(); return maybeGetMethod(proxyClass, "setFlashlightEnabled", boolean.class); } private static Method maybeGetMethod(Class<?> clazz, String name, Class<?>... argClasses) { try { return clazz.getMethod(name, argClasses); } catch (NoSuchMethodException nsme) { // OK return null; } catch (RuntimeException re) { return null; } } }