Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I have an interesting issues and wanted some input from someone with a similar experience.
I have an Android app that makes a REST call (e.g. accepts an open order). App sends out the request and runs into connectivity issues, meanwhile server gets the request, changes order state and sends back a response (e.g. HTTP 200). But, the app, missing its network connection, does not receive the response and gets an timeout exception. If I try to accept the order again, I get response that it is already taken (in this case by me).
The question would be - what should be the best approach to such situation.
For now, the requirements are to run a loop if I get a timeout exception (in some scenarios it's a loop including another web call to check whether this order did not appear in my "CurrentOrders"). I don't like this design and was wondering what would be better. Maybe the web call could return 200 (success) if the same client tries to accept the same order twice or more? Or how would some of you handle such situation?
I'm not quite clear about the semantic of your "accept" action.
What does it actually do?
On the one hand it seems it updates the order state. It should be then idempotent since further updates should not change anything.
On the other hand you have some kind of external state (order is taken). This can't be done through REST, you have to use some kind of unique id to resolve the conflict. Look at this question for more info.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Currently, I am struggling to show the internet speed consistently in the status bar. What I am able to do is, finding the internet speed by the old approach(Upload & download some file from/to server and using TrafficStats API). I tried some of the play store apps, they all displaying the internet speed when the user opens up any app which uses the internet. I want to implement the same feature. I believe they either use a broadcast receiver or service. How can I implement the same?
Or is there any library which does the same or any other better approach?
The problem with displaying an internet speed is that it is always going to be 'historical' or an estimate - i.e. even if you were able to achieve 300Mbps 1 second ago it does not mean you will be able to achieve it now.
Bearing this in mind, the approach you already outlined is as reliable as any - i.e. measure the round trip time for a known size of data. If accuracy is important to you, this is probably the most accurate provided you are confident of the turnaround time on the server side.
You can listen to Android Network events which will tell you when the type of network connections has changed etc - the recommended approach has changed over API levels but this is a good starting point: https://developer.android.com/training/monitoring-device-state/connectivity-monitoring
For your example it sounds like you want to get as recent as possible Network Stats rather than connectivity changes - for that the 'NetworkStatsManager' is probably the best match.
Provides access to network usage history and statistics. Usage data is collected in discrete bins of time called 'Buckets'.
https://developer.android.com/reference/android/app/usage/NetworkStatsManager
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Say I pass a search Query to a forum board and I want to retrieve all the posts tags from the search on said forumboard.
How could I use android to parse all the posts?
I am lead to believe that I should utilize some form of API.
Can someone guide me down the right path?
I do not have a specific forumboard software in mind, if any forum softwares have good API please let me know.
Okay so you are making a site that allows users to post things(?) and you can tag them. Just like here on Stack Overflow they allow you to tag your question and you can include that in the POST your website sends back to your server. Now you can send all sorts of information back to your servers including profile, question, tags, time of last update, etc; it really is limitless.
Now once you have that, if it is your own site you can then incorporate the Swagger API or whatever API you want, or you can hook your android app directly to the server and implement the same search features there as on the website. Once you have that determined, if you want to use an API for your app then you will need to look at AsyncTask for android. This little handy task can crawl the website in the background and return whatever you want, including API information if that is what you want.
I know this answer is broad but your question is broad, you have to start from the ground up and it can be challenging but remember that in order to get good at something it takes time, and if this is something you really want to do then it's not time wasted.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am already aware of the advantanges of retrofit and have used it in many scenerios. For a particular application , I need to call only 1 login API which will do authentication.
I am not sure if the advantages of retrofit are worth it for only one API. or is it a overhead and I should Http for sake of simplicity
If it is just a single request, then I'd say go with the simplest/lightest approach. But these things tend to evolve with time, therefore you are likely to find yourself in a position of adding another one, then another one...
Remember - networking mechanism is not an architectural decision. In fact, your application should not care what networking mechanism is being used - it should depend on a general interface that you define. You could start with implementing this interface using the simplest approach, and add a more complex implementation in case your networking requirements evolve. You could also implement several approaches and benchmark them...
So, whatever approach you choose, I recommend not to "pollute" your business logic with networking logic, but hide it behind interface. This way even if you make the wrong decision now, it will be a matter of few hours to fix it later.
For a single API call http is fine. As you know using library with your application is going to occupy user phone space when they install your application on their device. so for a single call, you are good to go with async task.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to send simple data between two phones. For example: When I press a button on device A on device B an action gets executed, for example, a sound gets played. How can I do this? Which methods would work well?
Thank you in advance.
You need a notification service, and google has something like that for us...
How does this works??
Take a look at the image posted over,
you need to register your android app in the google service, and your web interface will need an id, so every time you want to push something to the android, your web interface instead will push it to the google server with the Id of the app, then google (no matter how) will localize your app, and even if its not running, they will get the notification,
behind the scenes there is a couple of thing that you must do, bu nothing like launching rockets from the NASA.
I will suggest to take a look to some tutorials
in order to start with the registration of your app, get the API key etc etc..
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i be wondering How to game calculate the time for completion of work?
e.x:clash of clans find something update are done.
i believe someone want say get the time by server.but even i be offline can receive notification which say done.even i do change clock of phone nothing change in game if i change time of phone.
The time that is used to determine the yield from objects existing in clash of clans is maintained from a centralized server.
If you wanted to build an app that would calculate the times required to do things in game I think the rout to go would be to
A) ask the developers for the code (unlikely to be fruitful)
B) reverse compile the code. (potentially illegal)
C) Hand document the times required for in game events to happen (game w/notes)
D) Do a literature review to find data on the game
From this Data you may be able to craft a sort of clash of clans advisory app, but I doubt it will be easy to dupe such a consistently maintained app with hacks as simple as changing you're clock.