how to get data from API in android component and pass that data to react native to render it on UI? - android

I am making a request to an API using retrofit and coroutines (following MVVM architecture) in the android component of react native project. Now I have to fetch all the data (products of a shopping application) in the android component and send that data to react native to render it on UI.
any ideas?

Related

Android app that communicates with a server-side script

I am new to android but have a term worth of experience with Java which isn’t much at all but have a decent understanding of the important pillars of OOP.
I have been assigned a task to create an android app the communicates with a server-side script. To give some background my teacher has collected around 400,000 data entries and placed them in a MySQL database and has written the PHP script that will query the database which returns the results in JSON format.
What I am required to do is create an android app that will query this server-side script to display the information in my app.
Where do I start to accomplish this? I currently have a very basic understanding of android having just gone through stuff like, Application Manifest file, resources, activities, views, services, layouts, resources, widgets etc.
Thank You
To fetch data:
Retrofit library (to fetch data)
https://square.github.io/retrofit/
GSON libarary (to parse data from .json to Java/Kotlin structure)
https://github.com/google/gson
LiveData from Android Architecture Components (to "wait" for data or "Observe" them)
https://developer.android.com/topic/libraries/architecture/livedata
To display data:
RecyclerView with ViewHandler pattern
https://developer.android.com/guide/topics/ui/layout/recyclerview
To store data locally:
Room library (as abstraction layer over SQLite)
https://developer.android.com/topic/libraries/architecture/room
Some extra features
Swipe-to-Refresh (to send new request after swipe from top) https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
Shimmer (to make loading more beautiful) https://github.com/facebook/shimmer-android
ConstraintLayout (as most modern layout for Android)
https://developer.android.com/training/constraint-layout

Communication of Android Services with Activity in MVVM (Model View View Model)

I have just started using MVVM in android using kotlin. I have created an Android Service which is just fetching user location. This service runs constantly on background and uses FusedLocationApi to fetch the location. I have been reading articles of using background services with MVVM. The most helpful article I found is this Android Service MVVM communicaton. It says that you have to use repository when android service and view model communicates. But I have also found articles that says that do no use Android Framework classes in View Model (Do not use Android Classes in View Model). I am totally confused that how you communicate android services with activity in MVVM. Either we have to use repository for it or how we can implement it.
Any help will be appreciated,
I think the post that you linked above is trying to say:
- Service has instance of the repository
- ViewModel has instance of the repository
- When data changes in service it needs to trigger repository (set new value there)
- This will trigger listeners in view model automatically because it is live data or it is some other reactive (observable) data source

Realm JS + Realm Android

I have a Android application where some part are in Java and some in React Native. I am using same database for Java and React Native. Everything works fine but if I change data from Java during React Native is running then I can not get current changed data in React Native, this data are available after restarting React Native. Is it possible force reload Realm in Realm JS and Realm Android for get current data?
Exapmple:
run application, data are "foo"
change data in Realm Android to "foo1"
load React Native and load data from Realm JS, it returns "foo1"
on background in Realm Android I am updating data to "foo2"
reload data from Realm JS but it returns "foo1" but I exepted "foo2" <-- PROBLEM
close application
run application and load data from Realm JS and it is returning "foo2"
Thank you

What is a good way to exchange data between ReactJs (not react native) webview and android native

Im loading page from Reactjs into webview .
Im fetching some data in async (current location) and want to send it to react component.
I need to communicate between android native and ReactJs component to update store .

Connect android application to asp.net mvc back-end

I'm currently working on an mvc project meant to keep scores for students on certain sporting events, we are using a context class to create database tables code first into an existing database, the writing and reading in mvc works completely, we have a certain actionresult that returns a list of results that a student got, working with a studentId.
For this project we are also building an android app in which a student can logg on and view a list of his results (which the actionresult in mvc returns)
In our database we also have tables that work with mvc4's simple membership provider.
I was wondering what the best way was to connect our android application with our mvc project to acces the actionresult that returns the list.
I've been reading about an asp.net services project which could act as a link between our mc project and our android project, but I was wondering if there was an easier way to do this
also I was wondering if it was possible to log in using the credentials from mvc4's simple membership provider on our android app
The best way i can think of is ASP .NET Web API, as your front end application will have UI on android calling JSON result from an Web Api controller will help. you can also host this application separately and call from android, MVC or any other front end application reusing code

Categories

Resources