Android Update TextView(News feed) from Server - android

I am trying to develop as part of my app a sort of news feed for the user. When the user opens the app there will be a box at the top of the app which includes a greeting and information about the user or other information. This information would be pulled from a server. I think I just answered my own question. Would an HTTP Get be the best way to go about this? So it sends a request then updates the textview or whatever according to the information it recieves from the server?

Use an HttpClient to get data from the network, but make sure you do this inside of an AsyncTask so your application doesn't stop responding.

Related

Send request from one android app to another app using a Web server

I am doing my Semester project of Android.I am making a food delivery app.The work I have to do is that the user will send the request to a nearest restaurant.
The restaurant will accept the request and deliver the desired order that a user requested.
I know I have to work with maps and webserver.Maps will be used to get the location of the user and I am pretty good working on that.I know how to connect the android app with webserver as well.
But, I don't know how the user from his app will send request to the restaurant app by using webserver.How the resturant will accept and which restaurant will accept (in my case a nearest restaurant should accept,but first I just need to connect the user with restuarant).
Need a guide or Tutorials how I should Start this.I am really confused.
I strongly recommend you use Firebase - [https://firebase.google.com/?hl=pt-br][1] - to receive/send messages throught web. It´s very simple to use!

GroupMe API Callback

So, I am trying to use GroupMe's API. The issue is that I don't really know how to get the users access_token once I send them to the site to login. I don't really know how to create a callback or how to use it. So to sum it up
I need to send users to this site
https://oauth.groupme.com/oauth/authorize?client_id=CLIENT_ID,
then they login and groupme sends them to here
https://YOUR_CALLBACK_URL/?access_token=ACCESS_TOKEN.
But I don't know how/where to create a callback url. Then I don't know how to send that access_token back to the app.
Thanks.
A callback URL is simply a url exposed by your app that groupme can redirect users to. The page can be anything, however, oftentimes it takes the user back to your app if it is a webapp, or tells the user to close the page.
The important part is that the url is one that the app controls, so that it can get the contents of the url that contain the token and other data.
If you are writing a web app, then the framework or language should a method or variable you can call or read to get the url. If you are writing a desktop/moble app, one way of creating a callback url is to listen on a tcp port and speak http to the browser. Another way is using a lightweight web server library, or use a lightweight external server like lighthttp and communicate using cgi/fastcgi. All that matters is that you can get the url that groupme se,t the user to.
If you need anymore help, you are using Oauth2 so search for help with that. Nothing that you asked about here is specfic to groupme, so you should be able to use any OAuth2 library.

How to edit Android Apps Content through Website ?

Is it possible to edit contents of an android app through web site? For example, contents in a page (videos, texts) & layouts (location, size, colours).
Yes it is possible using like Client and Server approach where your Android app works like Client and your Website is like Server.
You can first download a data and store that data into SQlite and whenever you open a application every time app request to Server asking for New data.
You an achieve this using Sync Date & Time. Like whenever a website update there data then change Date & Time and when your request New data will check Date & Time. If Date & Time change then your app show update data message or New data available message. In this way you can achieved.
I think its not possible directly but sounds like you are about to use wrong pattern. The right pattern is a client-server one, where android app is a client and website with REST or any other custom API is a server. Application should request data from server and display it in a way you set up. So you will edit any data on a server and your app will receive changes on request.
I am not sure what you are trying to do but with any UI field, you can code it programmatically. So for instance, you have a button and want to be able to change the text on it, you can technically do this via a website:
You will need some sort of database management system that will control the content of the app. The app will just have to call the database to get all the data/fields it needs. You will pretty much be making a content management system for your app.

Facebook SDK for Android: Trying to get a notification when one "likes/comment" the post made by my Android app

I'm fairly new to Facebook SFD for Android.
What I'm trying to achieve is an Android app that uses facebook login, post to the user timeline and gets notified whenever one is commenting or liking that post.
I went thru Facebook tutorials for login and for Publish to Feed.
All went well.
Now I'm struggling with the last part. I don't see how to be notified whenever there is a like or comments. I browsed the web and stackoverflow forum without any success. I'm guessing that there is a mechanism to be notified by Facebook and that I don't have to start a process just to monitor the post...
Anyone could give me a hint on the API to use?
I'm currently looking at "Creating Object Types" section Associating Actions with Object Creation (https://developers.facebook.com/docs/opengraph/creating-object-types) but it looks like this describes how to do for facebook web app, and not for android app.
EDIT
I've found this https://developers.facebook.com/docs/graph-api/real-time-updates/ but not quite sure how to "translate" this into Android coding.
If anyone could help me with this, it would be greatly appreciated.
I guess you have to create a page in php that will handle the responses from Facebook, it starts with a
GET response from Facebook that you retrieve with $_GET["name"] in php, and you have to send back a confirmation to Facebook to confirm that the connection works, and Facebook will send you the answer you want via
a POST request ( $_POST["name"] ) (with a json object, containing the informations about the user in object for example, and the different updates in entry).
You can put all these informations in a database, and when the user start your application, you can automatically connect him to a php script that check if the database has new informations for him.
(specifying who he is, with a user variable that he keeps in the memory of his device, and then you ask for informations from the database about this user). I haven't tested, but it should work.

How to make database uptodate without any user request?

I am trying to develop an application which will download some json strings(greetings) from server .As I am new to android,I don't know exactly how to do that.The application will have its own inbox which will be implemented through sqlite and system will download all the latest greetings(json strings) automatically from server and will put them in the inbox.So what is best approach for this,I mean should I use SERVICES or Async Tasks for it ???I want that whenever a new greeting comes to the server, my application should download it automatically without any user request and when user opens the inbox,it is uptodate.
Services are more appropriate to the use case that you have described here. services are meant to be used in the scenarios when you are not sure when the data will be arriving and you want to keep checking for it in the background without letting the user know that something is going on Asynctask on the other hand is more useful when u need to do some network dependent thing or something that will take time after a user clicks on something.The asynctask is just another way to show the user a proper waiting progress bar or something while the application is processing the user's request so that the user doesnt feel like the app is stuck. So SERVICES it is for your case.
if you want to update the database even if the app is not running you will need a service or a sync account
for services
http://marakana.com/forums/android/examples/60.html
for the sync adapter
http://developer.android.com/resources/samples/SampleSyncAdapter/index.html
I implemented something similar using a service

Categories

Resources