Is there any way to detect whether LL is the currently active launcher; or, failing that, the currently configured…
Is there any way to detect whether LL is the currently active launcher; or, failing that, the currently configured default launcher?
I’ve googled the subject to death and scoured the API docs, but to no avail. I thought I had found the solution when I chanced upon LL.isPaused(), but no matter where I call that method, it always returns true.
]]>
< ![CDATA[
Using the Android APIs, I think you should be able to use:
http://developer.android.com/reference/android/content/pm/PackageManager.html#resolveActivity(android.content.Intent, int)
The intent for the launcher can be built like this:
var intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME)
]]>
< ![CDATA[
Thank you, Pierre Hébert.
I’ve been playing with this code for the past hour, but I’m having trouble getting further with it.
I’m trying to find the solution on my own, but I need just a little more help.
After reading some more about the Android API, I currently have this:
LL.bindClass(‘android.content.pm.PackageManager’);
var intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
var dl = getPackageManager().resolveActivity(intent,
PackageManager.MATCH_DEFAULT_ONLY);
var name = dl.activityInfo.packageName;
But when run, I get this:
At line 8: ReferenceError:
“getPackageManager” is not defined
Well, yeah, that method seems to be a part of the Context class, but then I’m not sure how to define a context or whether I even really need one.
I’m a programmer, but not a Java or Android programmer, so I’m struggling here.
Can you nudge me a little further in the right direction?
]]>
< ![CDATA[
No problem, from using a launcher to code with JavaScript and Android API, there’s more than an awful gap.
You are on the right track! Retrieve a context using LL.getContext() and I hope that alert(name) will display the package name of the currently selected launcher app.
]]>
< ![CDATA[
Ha ha, so I was missing only one line of code? I didn’t realise I was so close. 🙂
Anyway, getContext() was indeed the key to success with this script. I’m not even really sure what an Android context is (I will google it after posting this), but adding that line of code is the answer. 🙂
Thank you very much!
And thank you for creating this launcher. I have only been using it for a few weeks, but I am amazed what is possible with it. I hope you will be able to continue its development for a long time.
]]>