JSON data on the Android mobile with App Inventor 2



Recently I have been experimenting with MIT app inventor 2 on the Web to check the development cycle and production time. It turns out that the platform is extremely productive and offers numerous features for Android app development.

In a day I have been able to develop a relatively simple app and in two hours I have produced a second version (had to include some error control).

THE APP SCENARIO
The app reads JSON data from a web server (user’s choice) and presents them in a typical listview. Each item in the list is clickable and activates a secondary screen with detailed info and social sharing functionality. This app scenario can be applied in numerous cases where various data or measurements are online and need to be presented in mobile devices.

THE CASE STUDY
The case study for this app development was eHealth. I have already developed an eHealth app for iOS and I wanted to see how this app could be developed for Android.

THE DEVELOPMENT PLATFORM
I have been experimenting with Android development for some years and I had to stick with the typical Eclipse-Andoid SDK solution. I did not yet had the time to experiment with the MIT app inventor platform so since the 2nd version has been made available this was a good time to do it. The rest of this post includes details on how to develop an app with the specified scenario on the app inventor 2 platform and publish it easily on Google Play Store.

HERE GOES
Lets suppose we have an app inventor account and we are already logged in.
We create a new project and give a name.
What we need for our application scenario is 2 screens. One for a listview (master) and one for the details. Lets start by developing Screen1 as is the master screen named by default.

Here is a complete view of the master screen and the components included:
Screen Shot 2015-06-20 at 10.29.56Pin It
The interface is a typical visual programming interface with Components and Properties and is extremely easy and intuitive, so there is no need to explain anything more here. All components have been dragged-dropped from the Palette on the left side under the tabs “User Interface”, “Layout” and “Connectivity”.

Moving to the Blocks section (top-right screen button) we are able to do the actual programming using the Scratch Programming paradigm.

First of all we have to define some Global Variables for easy access throughout the app:
Screen Shot 2015-06-20 at 10.41.15Pin It

경축! 아무것도 안하여 에스천사게임즈가 새로운 모습으로 재오픈 하였습니다.
어린이용이며, 설치가 필요없는 브라우저 게임입니다.
https://s1004games.com

Then we move on to define the main app procedure, what we need our app to do:
Screen Shot 2015-06-20 at 11.24.52Pin It

Ok we are now done with this simple app and we just need to define what goes on in various cases that something happens, i.e. to handle the events in this app.
First we need to define what happens when the app loads:
Screen Shot 2015-06-20 at 10.45.31Pin It

Then we define that at each Timer tick we want to check new JSON data from the server in case the user needs to get live feed of the data:
Screen Shot 2015-06-20 at 10.46.58Pin It

In addition, we have to define what happens when the user uses the controls (the Go button and the live checkbox):
Screen Shot 2015-06-20 at 10.47.58Pin It

Two more things need to be defined: what happens in case of errors, and what happens in case the user clicks on a list item:
Screen Shot 2015-06-20 at 10.50.02Pin It
Screen Shot 2015-06-20 at 10.50.32Pin It

It should be noted that the Detail Screen (the 2nd screen in this project) has already been defined and named as “DetailScreen”.

The final touch is to program what happens when the app receives JSON data from the server and how the listView is actually populated:
Screen Shot 2015-06-20 at 10.53.09Pin It
It should also be noted that the JSON parsing algorithm presented in the previous figure is valid only for JSON data in the form shown in the following figure and should be carefully changed in other cases:
Screen Shot 2015-06-20 at 11.27.25Pin It
This concludes the Master Screen named “Screen1”.

We then move to develop the Detail Screen named here “DetailScreen”.
Here is a complete view of the master screen and the components included:
Screen Shot 2015-06-20 at 11.01.50Pin It
Again, there is no need to go into detail, since the Properties are more than obvious. Only one explanation that the “Share” and “Tweet” images are typical Buttons with their face changed using images.

Lets move to the “Blocks” section, again and take a look at the programming.
Here is the definition of Global Variables and the main Procedures:
Screen Shot 2015-06-20 at 11.10.32Pin It
It should be noted that the “get start value” Component is what the Master Screen passes to this Screen, and the the main Procedure creates a simple listView with the passed data from Master Screen and some additional data (here just some mobile device sensor data for reference).
Here are the Screen initialization methods, including what happens when the user requires to return to the Master Screen (presses “back”):
Screen Shot 2015-06-20 at 11.11.04Pin It
Please note that the CustomerKey and CustomerSecret are to be defined by each developer.
Here are the Social Media methods:
Screen Shot 2015-06-20 at 11.11.24Pin It
And finally a simple error handling method:
Screen Shot 2015-06-20 at 11.11.33Pin It



[출처] http://georgepavlides.info/json-data-on-the-android-mobile-with-app-inventor-2/

본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
번호 제목 글쓴이 날짜 조회 수
33 [안드로이드 Android] 시스템 인텐트(Intent)를 이용한 전화걸기, 문자보내기, 이메일보내기 etc file 졸리운_곰 2016.03.05 1099
32 Intent를 사용한 첨부파일 이메일 보내기 file 졸리운_곰 2016.03.05 2117
31 android app gmail 보내기, 안드로이드 E-Mail 보내기 예제 따라하기 file 졸리운_곰 2016.03.05 267
30 android 실행시 class not found 졸리운_곰 2016.03.04 180
29 android 부팅과 함께 app 실행 시키기. 졸리운_곰 2016.03.02 168
28 [Android] 부팅시 서비스(Service) 재실행하기 (항상 실행) 졸리운_곰 2016.03.02 347
27 안드로이드 시스템 부팅시에도 프로그램 항상 실행 (재실행) 졸리운_곰 2016.03.02 705
26 App inventor 멀티스크린, 스크린 이동, 다중화면, file 졸리운_곰 2016.02.17 779
25 Communicating with Web APIs file 졸리운_곰 2016.02.17 1080
» JSON data on the Android mobile with App Inventor 2 file 졸리운_곰 2016.02.17 364
23 REST clients for Java, MySQL and JSON Restful Web Services file 졸리운_곰 2016.01.11 223
22 안드로이드 개발 시 참고될 만한 자료 (android reading) 졸리운_곰 2015.11.11 4299
21 14 Great Android apps that are also open source file 졸리운_곰 2015.08.19 134
20 안드로이드 오픈소스 프로젝트 리스트 file 졸리운_곰 2015.08.19 433
19 ART(Android Runtime) file 졸리운_곰 2015.08.05 343
18 2014_CodeEngn_Conference_10_안드로이드에서도_한번_후킹을_해볼까_(Hooking_on_Android)_[정광운].pdf file 졸리운_곰 2015.06.16 248
17 안드로이드 커널 레벨 후킹하기 file 졸리운_곰 2015.06.16 1022
16 Android SDK 안드로이드 소스코드 난독화 file 졸리운_곰 2015.05.31 1254
15 안드로이드 프로그래밍 강좌 모음 졸리운_곰 2015.04.14 458
14 Nexus 기기 초기화 졸리운_곰 2015.04.10 295
대표 김성준 주소 : 경기 용인 분당수지 U타워 등록번호 : 142-07-27414
통신판매업 신고 : 제2012-용인수지-0185호 출판업 신고 : 수지구청 제 123호 개인정보보호최고책임자 : 김성준 sjkim70@stechstar.com
대표전화 : 010-4589-2193 [fax] 02-6280-1294 COPYRIGHT(C) stechstar.com ALL RIGHTS RESERVED