Android network programming to obtain JSON data instances on the network
In order to obtain JSON on the network, you need the support provided by the server.
1、 Create server side:
Server side project structure:
Server side operation rendering:
Step 1: create the JavaBeans required by the business
Step 2: create business logic interface and concrete implementation class
Business interface:
Implementation class of business interface:
Step 3: create controller Servlet
Step 4: create the jsonnewslist.jsp page
So far, the server-side project has been completed. Let's start creating the Android project.
2、 Create Android client:
Android end project structure:
Step 1: create the JavaBeans required by the business
Tip: because both server-side and Android side projects are implemented in Java language, some components can be shared, and JavaBean is one of them. At this time, we can use JavaBeans in server-side projects when building Android side projects.
Step 2: create the business logic layer of Android end project
Core code: getandparsejason:
Step 3: create an activity
So far, the Android client project has been completed. Let's take a look at the running effect of app: Android running effect: