[GUIDE][Difficulty: Intermediate] Read a Random Top Voted Thread from Reddit - Tasker Tips & Tricks

I'm sure many users here have heard of or currently use Reddit, the link aggregation website. If you use the website for news, to find funny jokes, to find awesome tips, etc. then you'll be happy to know that Reddit offers the ability to read data from its subreddits in the form of a JSON feed, and using Tasker we can process this feed to get the data that we want, in this case the titles of each thread. In my setup, I'm taking a random title among the top 3 posts of the day from /r/quotes.
Instructions
Variables --> Variable Set. Name %subreddit to the name of a subreddit you would like to pull from.
Variables --> Variable Set. Name %numposts to whatever number of posts you want to pull before randomizing which one is picked.
Net --> HTTP Get. The Serverort you'll be grabbing is:
Code:
json.reddit.com/r/%subreddit/top/?sort=top&t=day
Code --> Javascriptlet. Here is the Javascriptlet you'll need to put under Code.
Code:
var arr = JSON.parse(global("HTTPD"));
var randomnumber = Math.floor((Math.random()*numposts)+1);
var selftext = arr.data.children[randomnumber].data.selftext
var title = arr.data.children[randomnumber].data.title
Variables --> Variable Clear. Set Name to %HTTPD* and check Pattern Matching.
Alert --> Say. For the text, you can say anything to preface what Tasker is about to put out. For instance, I've said it to "Your quote of the day is: %title." This should change depending on which subreddit you pull from.
That's it! Pretty simple to start with. You can change the Javascriptlet to pull N number of threads into an array and mess with that if you would like. Tasker's Javascriptlet user guide is a great resource for this.

Would you mind posting the xml file? Thanks!

Did exactly as you said and it doesn't work.
Edit : Darn this is a pretty old thread
Sent from my Honor 6X using XDA Labs

Related

AnyCut / BetterCut

Well I have been searching around now for instructions on how to use this app.
Specifically the "Make Your own" Option on the app.
With all these shortcuts im about to show you Leave Type section blank.
here is what I found.
The app uses something called URI (Uniform Resource Identifier).
These are used to Choose what you want to do in the specific shortcut.
i.e Make the short cut a Direct Call. the URI I believe is this:
Code:
Action: android.intent.action.DIAL <--- URI
Data: content://contacts/people/#
# meaning the number defined to the specific contact. You can also use their Phone number as well if it gets too complicated.
What you typed into the Data portion is the what the URI is going to go into to make the shortcut work. In this case, It dials the specific number typed in where the # sign is.
To make a Direct Song shortcut you would have to do this:
Code:
Action: android.intent.action.PICK <--- This will choose and play the song you choose in the Data sections.
Data: content://media/external/audio/media/# <-- This specifies what song you want to be played.
# the same applies as with the direct call except that it can only be one number (i.e 1 for your first song, 2 for the second song, 3 for the third, etc etc)
Im not sure if combining numbers would work in this case but I doubt it.
--------------------------------------------------------------------------
If anyone finds anymore information, links, or w.e on it or more shortcuts that you guys have made, please post them and I will add them onto Here.
More Information/Links:
http://developer.android.com/referen...nt/Intent.html
If link is broken for you search this in google:
developer android referen Intent
and choose the very first option.

Development question - error resource file has much lines

Hey buddies. On my app to pebble, on IDE CloudPebble, I created a new resource, is a simple txt file, but this file have 3000 lines. If I cut some lines, the app install normally(example 500 lines), but I want that it read all txt(the 3000 lines). To read, I use the recomended functions of Developer GetPebble, after I add the strings to a array 'n execute a function, after this array is cleaned, to read a new line of strings. Exists a configuration to resolve this? I really want read all lines. I don't wanna install it app into pebble smartwatch, I created it app only to test, before use into watch without read the resource file, only capturing data of accelerometer.
Language C.
Resource type: Raw Binary Blob.
This file has 78,5 kb. Thanks!

Help with comparing variables

This is probably simple for a programmer, but as a newb, I am getting stuck.
I have 2 variables and I want to check if the first is contained in the second
so, %event = Phone and %check = WorkPhoneReport
I have tried :
*%event* ~ %check
*%event* ~R %check
*%event\* ~ %check
And several other similar patterns. What to do to get this test working?
I am trying to read my calendar and not process the same event a second time. So, each item it reads is appended to another variable, then on its next loop, it compares the new event to the check variable to see if it was processed already. Don't know if I should be using an array instead of a variable, and if I can use an array in a if/then statement....
Any help is appreciated!!
Figured out a way.
Variable Search and Replace:
Variable %check Search %event store in %matches
then in the if statement just check if %matches is set.
If there's a simpler way, please let me know, this task is at 50 commands, never hurts to shorten it.
Code:
%check ~R .*%event.*
In Regex format, dot (.) can be any character including having no character there, and star (*) means repeat previous character as much as possible.
So .* means "look for no character or any number of any characters", and .*%event.* means "look for %event with something or nothing before it, and something or nothing after it"

Send data to multiple activities

Hello,
I am new to android studio and java in general. I was wondering If there is an easy way to send data from one activity to multiple activities.
On my first activity the user will enter some text. I want this text to be displayed on the second activity as well as on a summary page(my 6th activity).
I have figured out how to have the text go from activity 1 to the second activity. But I cannot figure out how to make it show up on the summary page as well. Anyone have any advise?
Thanks in advance!
NewtoStudio said:
Hello,
I am new to android studio and java in general. I was wondering If there is an easy way to send data from one activity to multiple activities.
On my first activity the user will enter some text. I want this text to be displayed on the second activity as well as on a summary page(my 6th activity).
I have figured out how to have the text go from activity 1 to the second activity. But I cannot figure out how to make it show up on the summary page as well. Anyone have any advise?
Thanks in advance!
Click to expand...
Click to collapse
You should use some permanent storage. In Android it's a lot ways to save the data: simple file, preferences, database, content providers and others.
I think for you case can be appropriate use the preferences. You need to write the preferences in one activity and read in another. Please see the following code example in Kotlin for details.
In order to write the preferences:
Code:
with(getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)) {
edit().putString(MY_MSG, "your message text").apply()
}
In order to Read preferences from destination activity:
Code:
with(getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE)) {
mString = getString(MY_MSG,"");
}

How do I rename spreadsheet columns and alter app to suit?

I have built an app from a tutorial but I am having problems adapting it to my needs. I need to rename the spreadsheet columns but when I do (and match the names in the app) if fails to get the data.
I'm not sure what spreadsheet you are referring to, but just going off my excel & VBA knowledge, can you check that auto calc is turned on? and/or hit F9 to recalc. How about the name manager section in the tool ribbon in excel? Say for example the column you want is called "variables" and it was originally defined as $A:$A (i.e., all of column A) but you did something and now it's been altered so that it's $A:$B (i.e., is all of columns A & B) then that could cause problems. Similar thing if it the area was smaller, like $A$2:$A$6. If you added a row to cell A7, the name manager is not looking past A6 in this example so your new info won't get a hit.
Hope that helps
I am using a google sheet to hold data for the app, one entry per row. I have tried with the code I have that builds the basic app. The tutorial app has first_name, last_name, email as column headers. I need them to be gridref, fallname, w3w. I have to name the data fields (?) within the app but if I use GridRef it fails but gridref works. can string names not have/be capitalised?
Also if I create a new project called WF the code I'm using works but if I name it waterfalls it fails.
I can rename them in the spreadsheet, there are no calculation fields etc. just simply text in a cell, typed in to be passed over to the app in JSON format.
I can add a new line which displays in tha app as a new entry which is what I want. I will need to add columns at some stage but I'll be happy to get this working first.
I have managed to rename 3 of the four columns but it fails when i change the name of the 4th That may not be a problem but changing last_name to aw3w causes an issue. In the app I think they are called 'holders', are some names reserved by the system?
I have figured this one out.

Categories

Resources