Web Shortcuts for all devices without installing other apps 😊

Web Shortcuts for all devices without installing other apps 😊

Script is in the first post after copying it open the script editor application and paste the script slide out the script editor drawer and tick the lightning menu checkbox so it appears under the scripts menu as shown in the video.

7 Commentsto Web Shortcuts for all devices without installing other apps 😊

  1. Jay M says:

    /*

    * Web Shortcuts

    * Create shortcuts to your favourite websites

    */

    LL.bindClass(“android.widget.LinearLayout”);

    LL.bindClass(“android.widget.EditText”);

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

    LL.bindClass(“android.content.DialogInterface”);

    LL.bindClass(“android.content.Intent”);

    var mctx = LL.getContext();

    var ll = new LinearLayout(mctx);

    with(ll){

    setOrientation(LinearLayout.VERTICAL);

    setBackgroundColor(0xffff);

    setLayoutParams(new LinearLayout.LayoutParams(200, 100));

    }

    var title = new EditText(mctx);

    with(title){

    setHint(“Title”);

    setLayoutParams(new LinearLayout.LayoutParams(-1, -1));

    }

    ll.addView(title);

    var url = new EditText(mctx);

    with(url){

    setHint(“Url”);

    setText(getClip());

    setLayoutParams(new LinearLayout.LayoutParams(-1, -2));

    }

    ll.addView(url);

    adb = new AlertDialog.Builder(mctx);

    adb.setTitle(“Configure Web Shortcut”);

    adb.setCancelable(false);

    adb.setView(ll);

    adb.setPositiveButton(“Create”, new DialogInterface.OnClickListener(){

    onClick:function(dialog, id){

    if(title.length() >= 3 && url.length() >= 3){

    try{

    var i = new Intent(Intent.ACTION_VIEW);

    i.setData(Uri.parse(url.getText().toString().trim()));

    var d = LL.getCurrentDesktop();

    d.addShortcut(title.getText().toString().trim(), i, 500, 800);

    var item = d.getItemByName(title.getText().toString().trim());

    item.setDefaultIcon(Image.createTextIcon(“n”, 250, 0xff000000, 0xffffffff, null));

    Android.makeNewToast(“Shortcut was created”, false).show();

    //LL.startActivity(i);

    }catch(anfe){

    Android.makeNewToast(“” + anfe, true).show();

    }

    }

    }

    });

    adb.setNegativeButton(“Cancel”, new DialogInterface.OnClickListener(){

    onClick:function(dialog, id){

    dialog.dismiss();

    }

    });

    var alert = adb.create();

    alert.show();

    function getClip(){

    var manager = mctx.getSystemService(Context.CLIPBOARD_SERVICE);

    var clip = manager.getPrimaryClip();

    if(clip != null){

    var text = clip.getItemAt(0).getText();

    return text;

    }

    return;

    }

  2. I like it… Thanks for sharing πŸ™‚

  3. Heather L says:

    I’m sorry to bring up an older topic, but I can’t get this to work. I added the script and when I run it, I’m able to enter the title and url and it creates an icon, but when I try to open it, it says it can’t find the application. If I go to select an application and choose my browser, it just opens the existing browser window and not the desired url.

  4. Jay M says:

    Thats weird :/ i dunno why it wont work its just a standard Android intent aslong as you have an app that can handle it, this should work. Do you get the message “Activity not found Exception” or something else? can you screen record?

  5. Heather L says:

    It did say activity not found. But I was able to adjust the code to work for my purposes so no worries! I created a new script for each link I needed.

  6. Jay M says:

    nice glad it was kinda useful 😁

  7. Jay M says:

    Looks like a few people have found this script useful so i’ve updated it to be a little nicer. Now you can just copy the website url to clipboard and the url field will be filled in automatically. The default icon was kinda wank so i’ve replaced it with something sexy πŸ˜‰ enjoy

Leave a Reply

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