# Including references in onResume Lifecycle

What's a more concise way to do this? It's way too verbose for my taste.

    @Override
protected void onResume() {
super.onResume();
TinyDB tinydb = new TinyDB(this);
Log.v(TAG + "BaseStartup.onResume", "onResume");
IntentFilter intentFilter = new IntentFilter();
// Get source of open for app re-engagement
mobileAppTracker.setReferralSources(this);
// MAT will not function unless the measureSession call is included
mobileAppTracker.measureSession();
//sceneTransport("resumeSession", "null", "null" );

}

• What does Log.v(...) stand for? View, verify, verbose, ...? I'd rather use a more descriptive name. – GeroldBroser reinstates Monica Nov 26 '14 at 4:15

You could use a loop to reduce the duplication:

List<String> extensions = Arrays.asList(
"ve",
"ev",
"we",
"wef"
// ...
);
for (String ext : extensions) {
}


But actually, it would be better to move hardcoded strings outside of java code. You could create a res/values/arrays.xml file like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="actions">
<item>tv.apps.v4.ve</item>
<item>tv.apps.v4.ev</item>
<item>tv.apps.v4.we</item>
<!--
<item>...</item>
-->
</string-array>
</resources>


And use it in the code like this:

for (String action : getResources().getStringArray(R.array.actions)) {
}


Does this work as intended?

Thread.currentThread().setPriority(Thread.MAX_PRIORITY - 1);


I don't know about this particular usage, but I do know that low level thread operations are not recommended in Android development in general.

Unless this usage is explicitly mentioned somewhere in the official guides, I'm not sure if this will work reliably at all.

One or even more additional addActions(...) methods in IntentFilter are another option:

public void addActions(String... actions) { ... }
public void addActions(String[] actions) { ... }
public void addActions(Collection<String> actions) { ... }


Following janos' answer and refactoring the loop into IntentFilter there's one line remaining in onResume() by using the second of those above:

addActions(getResources().getStringArray(R.array.actions));


Furthermore, I guess there is already a String[] actions; or Collection<String> actions; inside IntentFilter to hold the actions. (What else can it be?)

Then you can remove the loop completely and use:

addActions(getResources().getStringArray(R.array.actions));


or

addActions(new HashSet<String>(Arrays.asList(getResources().getStringArray(R.array.actions))));