Developing an Android Client Server app - android

I am developing an app as follows:
Android APP (As a client)..it will send data to a Server (Java application running on a PC).
I implemented this using socket programming and it is working. I have following issues:
When I click the send button on my app the APP UI freezes for ~7 seconds. It is able to ping and connect to server but during this time frame the UI freezes and if I click any other button on the app I get a message app is stuck (but the app comes back ok after ~ 7 seconds). What is the best way to resolve it.
Once data (strings) is received on the PC, I want to show it in the form of List Box UI so that user can select/double click on the specific string and a message box is open showing that that particular string is selected. What is the best way to develop this UI and how can it be invoked directly as soon as server receives the data from Client (android app) and this UI should show up.
Please let me know. All help is appreciated.

Place all your network-related code into a separate thread, or (easier) and AsyncTask. Otherwise, you would block the UI, as you have noticed, and the app would actually crash on newer Android versions (ICS and JB).
If you search SO and the interwebs, you will find plenty of examples.

Related

Android use of mobile data when in background

I have developed a hybrid app running on Android, that successfully monitors the users location and displays it to the user as a moving icon on a map. This part of the app is all written in javascript and works inside a webview. The webview also communicates with my remote server to share the user's location with other users of the same app.
Up until Android Nougat this all works even when the app is backgrounded for several days. When the user returns to the app they can see where they have been with timestamps at each point. And all the other app users can see where everyone is, even if they are no actively using the app.
From Android Oreo onwards, I had to move the location tracking to a background service to get it to continue in the background and I have tested this to be still working fine even with the app in the background for a long period. Returning to the app, the user can still see where they have been. However the remote communications to the server, on Android Oreo and later, cease after approximately 2 minutes in the background.
Please could someone explain why this is, and what I could (if anything) do about it?
What is the restriction that I am running into and where is it documented on Android developer? I have set the app as not to be limited in settings/network/data saver and this makes no difference.
Would it make a difference if I replaced the webview XMLHttpRequest with similar code in background service, using volley or something similar?
All help very much appreciated.
Although I have not discovered what restriction I am running foul of, I have found that by moving the http request from the web view to the background service using volley, the server continues to be updated whether or not the application is in the foreground.
Only tested so far on Android 8,9 and 10 in the emulator. Testing soon on a real device

connecting an android app to a server and make it run a python program with input taken from the app?

The Android app I am supposed to develop takes only one integer as input. I have to implement the app in such a way that when a button is pressed, it needs to start an execution of the program in the server, then take an input from the user and send it to that process which is being executed. Then after the execution the server should return the output to the Android app. I would like to know any method to solve this problem. I have tried searching over the web but could not find good solutions to solve the problem.

Monitor any other running app from a service Android

I was developing an app for an enterprise which has given the employees an android phone, they wanna monitor every time a user tries to open any other app and send a report to a manager so I´ve developed an android service that checks every time any other app is call meaning: OnCreate, onResume, etc.(that´s done) Now they wanna check what that particular user did once he got into the other app: for example if he opened the messages(com.android.mms) , what message he sent or what he had recieve. other example: if he opened the dialer(com.android.dialer) they wanna know what phone he called. What makes it tricky for me, is that they want this for EVERY POSSIBLE APP a user can have installed in their phone.
My Question is the following: is there a way to capture this kind of information of a running app, from a service?
I appreciate any answer and I´m open to suggestions of how should i do this.

Sending E-Mail or Sending data to Server in Background

Im wondering if there is a way in android to run tasks in the background by just using the android packages without using AsyncTask. What i imagine is a background task which is still running when the Activity is already finished or the app already got closed. I want the user to see the progress of this task in the notification tab of android (the tab you can swipe down from the top of the android screen).
I want to do this for example when i send e-mails or when i send data like images to the server. because they are quite long running tasks i dont want the user to wait for them to finish. i want them to run in the background so that the user can close the app. and i want the user to see the progress in the notification bar.
Also i would like to know if there is a way to automatically repeat such a background task when it failed because the device did not have connection to the internet.
Im looking forward to read the answers and to learn something new.
You must use service.
I think these links can help you to use it:
http://developer.android.com/training/run-background-service/index.html
http://inchoo.net/dev-talk/android-development/android-simple-service/
Download a file with Android, and showing the progress in a ProgressDialog
Example: Communication between Activity and Service using Messaging

How to remotely update android app information?

I am working on an app that would have a couple of text views that change based on menu items. I currently have a method for doing this involving socket communication between a constantly running server and the app, but I don't want to have a constantly running server and computer. Is there some way to send an update (without updating the entire app) to send menu changes from a computer to the app? Thanks for any and all help, I will clarify if needed.

Categories

Resources