Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialfadhil suhendi
7,680 PointsUsing API weather forecast for java desktop application
Hi,
Im just a bit curious about the API thing. Can we use this API to build java desktop application ? and is it going to be similar with the android in terms of the code ?
thank you,
2 Answers
cbcbcb
16,560 PointsYes.
The data is formatted using the JSON specification. The reason that the code is being wrapped up into this formatting is specifically for the purpose of setting up and tearing down each objects as they are sent from an endpoint on a server to the user's device.
The main difference you're going to realize between the two implementations is without a doubt going to be that the Android mobile operating system consists of a stack of software. This stack includedes a framework that we the developers rely on to instantiate objects from, retrieve data from the user directly or if desired via the internet..
So now that we understand that the Java SE JDK is a set of APIs for using the standard edition / core Java programming language let's go deeper into the last thought when I mentioned a stack of software. I find it helpful to visualize the Android phone as a stack of cards where each cards is only responsible for acting as a mechanical controller arm that meets some data contract. A great example of this kind of implementation within the point would be trying to see whether or not there is network connectivity to either mobile data and/or 802.11x wifi. You would initialize a class of a given type and then assign it a reference to some sort of a manager object that is returned via an implementation of a method that returns an instantiation of itself.
On Java for example you would need to write both modules as the Java JDK is not a full stack or system. So everything will be different in places where Android provides an API for a certain implementing a core component and/or ensuring a requirement. For example the Andorid data persistence framework involves both SharedPrefeferences as well as a SQLite kickstarter implementation. Since SQLite is embedded within each application and therefore integrated into this stack of software it would be highly unlikely your choice for storing the data would be the same.
However I should point out that when referring to these core area like data storage it is important to understand is that the PROCESS by which you go about writing the data or in the current context pretending we are working on a broken system at a restaurant. This however in no way affects any lower and/or upper bounds in respect to the data members' field values.being used as comparators in the the conditional evaluation statement. Therefore the PROCESS doesn't really change but the implementations used to attain the required result is often dynamic and not discovered until runtime.
EXAMPLE
private static boolean userNameValid( )
{
if( this.mUsername.length < mUsername.MAXIMUM
&& username.length > USERNAME.MINIMUM )
{
return Username.sUsers.contains( this.mUsername.getData( ) );
}
}
Jakub Farobek
1,959 PointsI used a weather API when I worked with a Java-based framework. If you can use http requests and can handle JSON, I don't see why you would not be able to do it. :)