Code example for Constructor

Methods: getParameterTypes, newInstance

0
			Class<? extends Task> clazz = (Class<? extends Task>) Class
					.forName(intent.getAction());
 
			Constructor<?> constructor = getConstructor(clazz);
 
			if (constructor.getParameterTypes().length == 1) {
				task = (Task) constructor.newInstance(this);
			} else { 
				task = (Task) constructor.newInstance(this, intent);
			} 
 
			onTaskResolved(intent, task);
		} catch (Throwable ex) {
			task = null;
 
			onTaskUnresolved(intent, ex);
		} 
 
		return task;
	}