Example usage for android.os BaseBundle getString

List of usage examples for android.os BaseBundle getString

Introduction

In this page you can find the example usage for android.os BaseBundle getString.

Prototype

@Nullable
public String getString(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:nuclei.task.TaskJobService.java

@Override
@SuppressWarnings("unchecked")
public boolean onStartJob(JobParameters params) {
    try {//from  www  . j av a 2 s . c o m
        if (sTaskPool == null)
            throw new NullPointerException("TaskJobService TaskPool not set!");
        BaseBundle bundle = params.getExtras();
        String taskName = bundle.getString(TaskScheduler.TASK_NAME);
        Task task = (Task) Class.forName(taskName).newInstance();
        ArrayMap<String, Object> map = new ArrayMap<>(bundle.size());
        for (String key : bundle.keySet()) {
            map.put(key, bundle.get(key));
        }
        task.deserialize(map);
        if (task instanceof HttpTask)
            Http.execute((HttpTask) task).addCallback(new JobCallback(params));
        else
            sTaskPool.execute(task).addCallback(new JobCallback(params));
        return true;
    } catch (Exception err) {
        LOG.e("Error running task", err);
        jobFinished(params, true);
        return false;
    }
}