I am creating an android app for my facebook page. The app is supposed to display random statuses(not just the recent ones) from the facebook page. Is there anyway I could do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I haven’t done anything of that kind ever, but I think you can gran some logic from this and get it to work.
Step 1:
Make a call to the Facebook API, get all Status Updates and in a
forloop, add them to anArrayList<String>. For example, Facebook returns its data in JSON format. I am assuming, you already know how to fetch data. You need to parse the “message” tag from the JSON data returned by your Facebook API call.For example:
Step 2:
Once you have your entire set of Facebook Status Messages, you will now need to use a
java.util.Randominstance.For example: (Please note: I have not tested this code and it might result in errors. You may have to play around with it a bit to get it to work. 🙁 )
Step 3:
Use the
strRandomStatusto set it on aTextView.For example:
You haven’t posted any code, so it is difficult to provide something that fits in your scheme of things. But I think this should get you started. You will, possibly, need to adapt a few things and fit them in your own code.
Hope this helps.
EDIT: As per a comment by th OP, adding some bits of code to fetch Facebook Status Messages:
in your
onCreate()method:Start a new AsyncTask:
I use this method in my app to make the Facebook Call to get all feeds from the Graph API.
You can do the remaining code, where you select a random Status Update, in the
onPostExecute()of theAsyncTaskshown above:Declare the
TextViewas a Global Variable and cast it on youronCreate()before calling theAsyncTask. I think this should work just fine. Let me know how it goes. 🙂