Bug 776027 - Move intent handling to IntentHelper. r=wesj

This commit is contained in:
Josh Dover
2014-04-14 17:46:00 +02:00
parent bff3e290ac
commit 104b9088bd
4 changed files with 156 additions and 65 deletions

View File

@@ -7,6 +7,7 @@ package org.mozilla.gecko.util;
import org.json.JSONException;
import org.json.JSONObject;
import android.os.Bundle;
import android.util.Log;
import java.net.MalformedURLException;
@@ -54,4 +55,21 @@ public final class JSONUtils {
throw new IllegalArgumentException(name + "=" + uuidString, e);
}
}
public static JSONObject bundleToJSON(Bundle bundle) {
JSONObject json = new JSONObject();
if (bundle == null) {
return json;
}
for (String key : bundle.keySet()) {
try {
json.put(key, bundle.get(key));
} catch (JSONException e) {
Log.w(LOGTAG, "Error building JSON response.", e);
}
}
return json;
}
}