Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;

import java.util.HashMap;
import java.util.Map;

/**
* Utility class with methods to launch CommCare
Expand All @@ -21,24 +22,28 @@ public static void launchCommCareForAppId(Context context, String appId, HashMap
intent.putExtra(SESSION_ENDPOINT_APP_ID, appId);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

extras.forEach((key, value) -> {
if (value instanceof String) {
intent.putExtra(key, (String)value);
} else if (value instanceof Integer) {
intent.putExtra(key, (Integer)value);
} else if (value instanceof Boolean) {
intent.putExtra(key, (Boolean)value);
} else if (value instanceof Long) {
intent.putExtra(key, (Long)value);
} else if (value instanceof Float) {
intent.putExtra(key, (Float)value);
} else if (value instanceof Double) {
intent.putExtra(key, (Double)value);
} else {
throw new IllegalArgumentException(
"Unsupported type for extra while launching CommCare: " + value.getClass().getName());
if (extras != null && !extras.isEmpty()) {
for (Map.Entry<String, Object> entry : extras.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof String) {
intent.putExtra(key, (String)value);
} else if (value instanceof Integer) {
intent.putExtra(key, (Integer)value);
} else if (value instanceof Boolean) {
intent.putExtra(key, (Boolean)value);
} else if (value instanceof Long) {
intent.putExtra(key, (Long)value);
} else if (value instanceof Float) {
intent.putExtra(key, (Float)value);
} else if (value instanceof Double) {
intent.putExtra(key, (Double)value);
} else {
throw new IllegalArgumentException(
"Unsupported type for extra while launching CommCare: " + value.getClass().getName());
}
}
});
}

context.startActivity(intent);
}
Expand Down