For me, when a ‘door opens’ and it has a lot of things at the other side, I sometimes get a bit shocked at the…

For me, when a ‘door opens’ and it has a lot of things at the other side, I sometimes get a bit shocked at the beginning, and it takes me time to try and get used to it.

It happened when the ‘Image update’, and specially with the ‘java update’.

Now, thanks mainly to Lukas Morawietz​, but also to the others scripters that published scripts with ‘java code’ I think I can now understand well and make my own ones.

I’m full of new ideas, but with less free time than in the past. So perhaps I will publish some ‘pieces of code’ without a specific use, but that others can use to make a useful script. (I have one to make a notification, another to edit an Intent, another to read the logcat…ask if you are interested)

Enough for now. This post is to share a script, so here it is.

Instructions: set it in the resumed event of an item (use a new shortcut, intent/icon/label will be overwritten)

The script ideally takes the last used app (that is not the launcher) and change the item to be as the app shortcut of that app.

It will take the default icon, no icon packs.

It can be buggy sometimes (I didn’t tested it a lot too), and maybe it throws an error, but I hope not to

The code is a bit messy, and I’m sure it can be improved

It can be modified to show more than one of the recent apps, but it is not implemented. Feel free to do so

Personally I’m using it now in my own screen to change the behavior of the HOME key. It will launch the previous app and the icon is placed under the HOME button (transparent nav bar) [although two more lines of code were necessary]

If you are still undecided to try all this new API features, think as if you can just use almost all android functions, only using the LL.bindClass() where necessary. Also in the java examples where it uses ‘this’ or simply nothing, in most cases you will need LL.getContext()

Thanks again Pierre Hébert​ for this awesome launcher.

]]>

11 Commentsto For me, when a ‘door opens’ and it has a lot of things at the other side, I sometimes get a bit shocked at the…

  1. Anonymous says:

    < ![CDATA[

    var MAX=10;


    var FORCEALL=false;


    LL.bindClass(“android.app.Activity”);


    var am = LL.getContext().getSystemService(Activity.ACTIVITY_SERVICE);


    var list = am.getRecentTasks(MAX,FORCEALL?1:0);



    var names=””;


    var last=””;


    var cmp=””;



    for(var i=0;i



    cmp=list.get(i).baseIntent.getComponent().getPackageName();



    names+=cmp+”\n”;


    if(last==””&&cmp!=”net.pierrox.lightning_launcher_extreme”)last=cmp;



    }



    //alert(names);//debug



    if(last==””)return;



    //set label and image


    var item=LL.getEvent().getItem();


    if(item==null){alert(“No item found”);return;}



    var pm=LL.getContext().getPackageManager();



    item.setLabel(pm.getApplicationLabel(pm.getApplicationInfo(last,0)),true);



    //convert the drawable to a LL image


    var bit=pm.getApplicationIcon(last).getBitmap();



    var image=LL.createImage(bit.getWidth(),bit.getHeight());


    var canv=image.draw();


    canv.drawBitmap(bit,0,0,null);


    image.update();


    item.setCustomIcon(image);



    item.setIntent(pm.getLaunchIntentForPackage(last));

    ]]>

  2. Anonymous says:

    < ![CDATA[

    with just what’s here I’ve found there’s no bugs yet. no need for Tasker no need for autolaunch and no need to manually refresh autolaunch everytime the device is rebooted. brilliant idea with just this.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Nice one! I love it!

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Well done. 🙂


    I’m using gravitybox for this, but it’s a cool solution, because it works without root.

    ]]>

  5. Anonymous says:

    < ![CDATA[

    I was using tasker and autolaunch to open the last app I was just in but it didn’t display the apps icon or name in the shortcut (i didn’t know how) but now I don’t even need that. with custom navbar (no root) I could open the last 2 apps is in. this script made my moms phone easier for her to use.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Thanks for sharing TrianguloY 

    ]]>

  7. Anonymous says:

    < ![CDATA[

    I have an issue when using the LL as lock screen. After unlock, the last app is not active.



    I thought of using this script. But it is not working even as explained by TrianguloY​

    ]]>

  8. Anonymous says:

    < ![CDATA[

    If you have that issue I guess you are on lollipop.


    On that version this script is useless (android removed the option to get the latests apps)

    ]]>

  9. Anonymous says:

    < ![CDATA[

    TrianguloY Yes, I’m on lollipop. Thanks.


    Is there a way to get the last app after unlock.


    I’m going to explore some plugins with Tasker.

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Without root, no.


    With root, I guess yes, but I don’t know.

    ]]>

  11. Anonymous says:

    < ![CDATA[

    Here what I did


    1. A plugin called Switchback for Tasker.


    2. New Task and select the plugin.


    3. Setup Swipe Up event of the Unlock desktop.


    4. Run shortcut and select the new Task.



    Done….

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *