change home screen.

Post your questions and help other users.

Moderator: Martin

Post Reply
3309
Posts: 9
Joined: 02 Mar 2014 16:44

change home screen.

Post by 3309 » 05 Mar 2014 13:41

http://automagic4android.com/flow.php?i ... dabdf04425


I like to change my home screen periodically. The random picture is from the get http method...from the flickr url...I need to use the split and replace methods.....I am trying but so for no luck. Do you have any demo to how to do split....replace, save the pic....like that
Appreciate the help.


Finally I did it
But is it possible to create a variable to store image? If it is I can make dynamic home screen change....

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: change home screen.

Post by Martin » 07 Mar 2014 07:59

You could download the file to a directory that contains only files you want to use as a wallpaper and then use the flow called Random Wallpaper from the catalog to show a random picture from this folder.
The catalog is available from the main screen of Automagic: Menu->Catalog, select Scripting and open the flow Random Wallpaper.

ma11en
Posts: 7
Joined: 24 Aug 2013 10:57

Re: change home screen.

Post by ma11en » 09 Mar 2014 09:59

I have a query on similar lines, I would like to create a widget that displays the current xkcd.com comic.

I've found a query that returns the following data in a file saved to my SD card;

{"month": "3", "num": 1339, "link": "", "year": "2014", "news": "", "safe_title": "When You Assume", "transcript": "", "alt": "You know what happens when you assert--you make an ass out of the emergency response team.", "img": "http:\/\/imgs.xkcd.com\/comics\/when_you_assume.png", "title": "When You Assume", "day": "7"}

How do extract the "img" url "http:\/\/imgs.xkcd.com\/comics\/when_you_assume.png" to download it please?

Regards Mark.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: change home screen.

Post by Martin » 10 Mar 2014 16:42

You could use the scripting functions indexOf and substring to extract the URL:

Code: Select all

// search the start of the url (the string is enclosed single quotes so that double quotes can be used without escaping with backslash)
i1 = indexOf(response, '"img": "');

//skip the first 8 charcters containing "img": " 
i1 = i1 + 8;

// search the end of the url, start searching where the URL starts
i2 = indexOf(response, '",', i1);

//extract the url
url = substring(response, i1, i2);
Alternatively you could use an unofficial function to convert the JSON to XML and use XPath to extract the value:

Code: Select all

//add an artificial root element to create proper XML
xml = convertJSONtoXML('"root":' + response + '}');

//extract the url
url = evaluateXPathAsString(xml, "//img");
Regards,
Martin

ma11en
Posts: 7
Joined: 24 Aug 2013 10:57

Re: change home screen.

Post by ma11en » 10 Mar 2014 17:27

Hi,

Thanks for this.

Mark.

Post Reply