Using Network Resources for currency converter - java

I have gone through the tutorials of using network resources in android. But I was not satisfied. What I am looking for is an way to get inside the webpage. The tutorials tell how to get to an URL. Well that is pretty simple as far as I can tell.
I am trying to make an currency converter app and for that I will have to get the exchange rates. How to do that exactly? This webpage gives an decent amount of exchange rates. I want to use this in my app. How can I do it?
Example-User selects an "from" and an "to" currency in the app. And that conversion should happen instantaneously. So for that I will have to get the exchange rates before hand and store them in the database. And If the user is offline,the app should select the last updated values.
Please help!

I would use an API; like this free open source one: http://josscrowcroft.github.com/open-exchange-rates/ to get the currency exchange rate as it would be impossible or at least extremely difficult to parse the data from the url you provided.
The API I suggested above will give you the rates you need back in JSON format which can be easily parsed in java.

Related

String Translation from API call

I have a found a free API to get some data I need for my app. The thing is the values that I get are in English.
I wanted to know if there is some way to translate this strings in my language before showing them to the users.
You can translate text but it will require another API call. Not only that, but you will have to create an appropriate request object and parse a response object from your chosen API.
You have various API providers to choose from, the top Google hits being:
Google: https://cloud.google.com/translate/
Yandex: https://tech.yandex.com/translate/
But beware! Machine translation is patchy at best. The likelihood of getting odd sounding or outright wrong results, particularly for anything other than simple text, is very high.

Android: Performance when calling Json file data multiple times from different classes

I'm working for my first time with Json files as data for my app, and I have been thinking about how is the best option to save a json file to make it accessible from different classes.
It is easy, I have a JSON file with different rated for currency conversions. I need to convert the data that I show in different currencies in different modules of my app continually.
So I just want to know a good way to store my json data and not load my Json file every time that I need to check a currency rate and find a way to do it more simple, maybe as a hashmap in my BaseActivity which is extended by the rest of my activities and just call it, or a static class with all the methods related with currency rates. I also thought about save it in a sharedPreferences.
It just a question for check the opinion of more people about the best way looking for app performance to continually call data from Json files.
I am not a financial expert but as far as I know currency conversion rates are applied on a daily basis. Also I have not worked on Android but the answer below is more problem-specific rather than technology specific and hence I assume that you would be able to map this to Android primitives.
I would hence design my strategy for maintaining the currency conversion rates as below:
Fetch the currency conversion rates the first time the app starts. Process this data and store it in memory within a HashMap for the lifetime of the app. Also, place this data into a more permanent store (e.g. SharedPreferences).
Refresh this data periodically using a service that runs once every
24 hours fetch the updated data. Process the fetched data in a
manner similar to above.
Notify the app that the currency rates have been refreshed. In case
the app is running it can referesh it's memory caches.
As about the class design - the hash map storing the currency exchange rates should be stored in a separate class say CurrencyConversionRateCache. This class exposes all method required for your activity classes to fetch conversion rates. The class also gets notified from the background service (possibly using Intents in Android) when new currency conversion rates have been downloaded. This way the cache itself is responsible for ensuring the validity of it's data keeping activity classes simple.
Hope this gives you some headstart towards solving your problem.

Get notification in my client code

I want to get the notifications about any change in any issues in my jira server.
I have basic code for connecting jira from java code using jira-rest-java-client library that they have provided.
I searched their javadocs and also went through some classes in that API library but I could not find any methods/classes which would be helpful to me.
Does anyone know if it is possible to get notification events from changes in jira to my java code (may be via polling or something like that).
What do you want to achieve?
You want to have push notifications? There isn't any, IMHO.
UPDATE: However, there is this WebHook thingy: https://confluence.atlassian.com/display/JIRA/Managing+Webhooks.
I have no expertise with it, but it is promising, please read this short introduction also: http://blogs.atlassian.com/2012/10/jira-5-2-remote-integration-webhooks/.
You are looking for something that gives you back what changed in the last N minutes, something like the Activity Stream? You can get the RSS feed of Activity Streams for Projects and for Users.
How
The base URL is https://jira.contoso.com/activity. Then you can append querystring parameters, like maxResults for paginating.
Selecting the data source is through the filters you provide in the streams parameter. It looks like it is JQL, but it's not.
Examples:
List a project's activites: ?streams=key+IS+SOMEPROJ.
List a user's activites: ?streams=user+IS+foobar.
List event between two dates: ?streams=update-date+BETWEEN+1425300236000+1425300264999. (Note: the epoch is the millisecond precision epoch.)
List user activities in one project: ?streams=user+IS+JohnDoe&streams=key+IS+PROJECTKEY.
More complex ones: ?streams=user+IS+JohnDoe&streams=key+IS+PROJECTKEY&streams=activity+IS+issue:close
Watch out, it is case sensitive, on my JIRA 6.1.9, if I write Is instead of IS, I get an error page (but not if AFTER is not all uppercase o.O).
Also note, that spaces should be encoded as plus signs (+), not URL encoded (%20 for spaces).
If you go to your JIRA, and fetch the following URL: https://jira.yourserver.com/rest/activity-stream/1.0/config, it will list all the combinations it accepts.
What
The call returns a standard Atom feed. You can then process it with XML query tools, or with other Java-based RSS/ATOM reader libraries.
Noteworthy document about this topic: https://developer.atlassian.com/docs/atlassian-platform-common-components/activity-streams/consuming-an-activity-streams-feed

How to implement custom search on the server database in Android 2.3?

I have to implement custom search in my application for android 2.3.I have some EditText in which user type one letter and then I send response to the server, retrieve all the results matches this one letter and then I need to display them in a list. When user types second button I also need to send new response and refresh data and so on.
The question how can I do this in Android 2.3? What should i use?
This seems to be too open ended with too many questions to give a really helpful answer.
What you use in your app will heavily depend on how the server's API is expecting you to communicate. I, for one, am all for hiding the specifics of what a server does from the application and put all the "smarts" behind the API. So a query like:
http:/blah.com/getresults?search=a
would result in whatever matches 'a'. If it is searching a MySql Db, processing a Google search, or accessing files on the system doesn't matter.
Your code needs to worry about the interface to the API to make queries and processing the results, whether they're free formatted text, JSON objects, or whatever.
Maybe rewording your question or provide information on what you know would help.

Getting data/information for android app use

I have been wondering about this, which is why I have put off learning app development for so long. Let's say I was making a school timetable app, that all the user had to do was enter the name of their course, and then the app shows the timetable for that course..
The questions is can I get information from the college or do I have to hard code it into the database myself?
How does one get information to use if they need it?
Thanks
It depends. Does the college provide you an interface you can use? Probably not one that was meant to be used by a third party app.
If not, then you have to somehow get the information into your database. Either per parsing their online HTML schedules or inputing it by hand (obviously always one of the last options to consider).
If the college had a website that you could view, you could scan the page for class listings and pull that data in - but more than likely that sort of data will need to be entered manually by you when you ship the app.
If college is having its website and the website provides RSS feed for time table you parse that XML file and show the data which is parse or you can save the time table information of which course in the database and display that using cursors.

Categories

Resources