Next code snippet: change the homescreen
Next code snippet: change the homescreen
Be aware that an invalid value may cause unexpected behaviour
]]>« Thanks to Pierre Hébert who teached me how to create apk’s! (Previous Post)
(Next Post) I really need to import js file on top of scripts. »
< ![CDATA[
//import java classes
LL.bindClass(“java.io.FileReader”);
LL.bindClass(“java.io.BufferedReader”);
LL.bindClass(“java.io.FileWriter”);
LL.bindClass(“java.io.File”);
LL.bindClass(“java.lang.System”);
//set Desktop with Id as Homescreen
setHomeDesktop=function(id)
{
//create the needed structure
var file=new File(“data/data/net.pierrox.lightning_launcher_extreme/files/config”);//this file contains desktop properties
var r=new BufferedReader(new FileReader(file));
var s=””;
//read the file
var l=r.readLine();
while(l!=null)
{
s+=l;
l=r.readLine();
}
//change the property
var data=JSON.parse(s);
data.homeScreen=id;
//write the changed stuff back to the file
var w=new FileWriter(file);
w.write(JSON.stringify(data));
w.flush();
w.close();
//restart the launcher
System.runFinalization();
System.exit(0);
}
]]>
< ![CDATA[
hey, see my post on the FileRW class 😉 to have a code more readable and extensive
]]>
< ![CDATA[
Maybe some kind of LL.reload() would help in reducing the “kludginess” level.
]]>
< ![CDATA[
to avoid restarting the launcher by the hard way? LL.reload() would be great I think!
]]>
< ![CDATA[
Lukas, how would i use this script? If i wanted to set desktop #2 as the home, i just call it and pass 2 as the data?
]]>
< ![CDATA[
Jordan Peters no, this is just a function which has to be called.
However you could do that by adding this line at the end:
setHomeDesktop(LL.getEvent().getData());
Note that if the Data is invalid (no number, too big number… ) this may screw your launcher, so don’t forget to backup before trying.
]]>
< ![CDATA[
Lukas Morawietz Pierre Hébert
1. Is there another way to change the homescreen, this code works only once, then I have to make manual change to work again.
2. Every time I run the script, the recent apps screen appear.
3. How to put the LL.reload, when I used it I hot an error.
]]>
< ![CDATA[
This will be supported through a new API in the next major version.
There is no LL.reload, but you can use LL.runAction(EventHandler.RESTART);
]]>
< ![CDATA[
Hi, sorry to bring up an old post, Is there any other way to set homescreen other than this script? By the way I get this script to work but only by kill the launcher, a restart (LL.runAction(EventHandler.RESTART);) aparently write the config file before exit, so this doesn’t work 🙁
Thanks!
]]>
< ![CDATA[
Other than manual configuration, no. This is the only way to set the home screen.
]]>
< ![CDATA[
Lukas Morawietz Thanks for the answer. Have a nice weekend
]]>