(EN) Android L API changes

I recently installed the Android L developer preview on my Nexus 5 and had to discover some really strange API changes.

The first thing I noticed was that IntelliScreen or, to be specific, it’s detection of the current foreground App didn’t work anymore. As this is necessary for App specific rules which are one of IntelliScreens main features, I definitely had to fix this and after some research I found this: https://developer.android.com/preview/api-overview.html#BehaviorGetRecentTasks
It seems, that the API to determine the current foreground App got deprecated in L and doesn’t work anymore because of privacy concerns. On the one hand that’s understandable but on the other hand, this is a really bad restriction because many apps like IntelliScreen rely on this API and it even had it’s own permission! Luckily I found a workaround:

appProcesses = activityManager.getRunningAppProcesses();
for (RunningAppProcessInfo rap : appProcesses) {
	if (rap.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
		//Foreground App found!
	}
}

This code just gets all running processes and then looks which of them have foreground importance. It doesn’t work as reliable as the old method and there are many unnecessary processes included but at least it works! Nevertheless this leads to the question why is this method still working? And more importantly will it still work in the final Android L release?
It really doesn’t make sense to remove one API for privacy concerns but still leave other (although more complicated) methods available. So I hope that Google fixes this in some way, preferably by reintroducing the old API or something similar.

Another strange thing is that lockscreen widgets got – at least in the preview build – removed! They were only shortly introduced in Android 4.2 and should now get removed again after slightly more than a year? That really doesn’t seem as they have a good long time planning! In addition to that, I found them really useful and DashClock – especially in conjunction with my custom extension 😉 – was one of my favorite apps with a fix place on my first lockscreen page. Of course you can continue to use DashClock as a normal homescreen widget but on the Lockscreen it was even more useful!

Luckily Android L is still a developer preview and none of the changes are final. So lets hope that Google fixes this and all the other problems for the final version because apart from that, Android L is really great 😀