use of org.robolectric.ShadowsAdapter.ShadowApplicationAdapter in project robolectric by robolectric.
the class ActivityController method getActivityTitle.
private String getActivityTitle() {
String title = null;
/* Get the label for the activity from the manifest */
ShadowApplicationAdapter shadowApplicationAdapter = shadowsAdapter.getApplicationAdapter(component);
AndroidManifest appManifest = shadowApplicationAdapter.getAppManifest();
if (appManifest == null)
return null;
String labelRef = appManifest.getActivityLabel(component.getClass().getName());
if (labelRef != null) {
if (labelRef.startsWith("@")) {
/* Label refers to a string value, get the resource identifier */
int labelRes = RuntimeEnvironment.application.getResources().getIdentifier(labelRef.replace("@", ""), "string", appManifest.getPackageName());
/* Get the resource ID, use the activity to look up the actual string */
title = RuntimeEnvironment.application.getString(labelRes);
} else {
title = labelRef;
/* Label isn't an identifier, use it directly as the title */
}
}
return title;
}
Aggregations