Troubles calling web services with WSDL Importer - android

I have built an application that calls a webservice in order to retrieve some information. This application is designed to work both on android and windows (using the firemonkey framework).
The object that calls the webservice has been built with a WSDL importer and works great when running the application on windows.
Nonetheless, when i try to use my application on an android device, i can only call the webservice two times. On the third time, the application freeze.
I have tried to do some debug and it appears that the application freezes when trying to call the web service :
genEtq := GetIGenerationEtiquettes(); // Converts a THttpRio as a IGenerationEtiquette object
soapattachmnt := genEtq.GetImageEtiquette(idEtiquette); // Calls web service -> freeze on third time
//
// Do something ...
//
The webservice is hosted on my computer so i'm sure there is no troubles on the service side. In addition, when i restart the application, i can still call the web service two times.
My application has the authorization to access to the internet on my android device so i'm running out of ideas on what's the problem.
Also i have tried to monitor the network (via wireshark) and i had been able to see the two first requests but not the third one.
Do you have any ideas on how to find the problem ?

Finally i have found the answer, my mistake was to call everytime the GetIGenerationEtiquettes() function instead of storing the resulting object.
Now i can call my webservice as often as i want.
Hope this answer will help someone.

Related

How to set alternate URL in retrofit android?

I Have implemented the node js rest API. That being use in my android app with the help of Retrofit. Now. If my app is in production and then somehow my main server will be crash. So, in that case I have a backup server that will work same as the main server do.
So, How can I set an alternate base URL in retrofit android? So, If the main URL does not work then call all API from that alternate URL. Is there any build-it functionality?
Or most welcome for suggestions, Any other alternative ways to implement this.
I have another suggestion for you.
A NodeJS server should not stop for no reason. Most of the time, it's because of a 500 Error that have not been catched and stop the server. So, at first, make sure that every js command that may cause error is inside try/catch block.
Then, I suggest using of PM2 package
This is the best option to run on a production server.
It has several advantages:
It's easy to setup and run.
PM2 will automatically restart your application if it crashes.
PM2 will keep a log of your unhandled exceptions - in this case, in a
file at /home/safeuser/.pm2/logs/app-err.log.
With one command, PM2 can ensure that any applications it manages
restart when the server reboots. Basically meaning your node
application will start as a service.
ref: https://pm2.keymetrics.io/docs/usage/quick-start/

Run code in background, Unity?

I would like to call a method every 10 seconds while app is closed. I have read that I have to create a service but I don't understand how. It would send information to a webserver (only personal uses).
Thanks guys!
If you want to send information to your webserver only while the application is running, you can use a thread within unity.
If you want some code to keep running, irrespective of whether or not your app is running, you need service. This should get you started on how to write a service.
You can write a small plugin in android native code, and include it's aar/jar in your unity project. Then you may send a message from your unity app via JNI to start the service. Totally depends on how you want to implement it though.
I have found a way of doing it. You can call a method via OnApplicationQuit() and this will run when the app gets closed. I have used this to get changes from my firebase database and send a notification when a child is added. It works. In this case you would have to subscribe to a method and this will run even if the app is closed. Then unsubscribe to this method via the OnAwake() method.
Check this
< https://developer.android.com/training/run-background-service/create-service>
You have to create a service but probably its very difficult for you.

Android AsyncTask case to freeze application on phone call received

My android application communicate with web services to download and upload data using AsyncTask. If i receive phone call during communication the application hanged up, else every thing is ok. how i can handle this issue.
Thanks
Try to use a service for these kinds of tasks, for fully understanding what happens it is better to take a look at Android's activity life-cycle:
http://developer.android.com/training/basics/activity-lifecycle/

Creating an Android Service with Phonegap? (Have phonegap app run even when closed)

I have been working on an Android app using Phonegap and now would like to make it so when the app is closed it can still execute the java/js code in the app. So I understand I need to create a service. If I create a service plugin on phonegap can I still execute the javascript code or only the java?
Has anyone does something like this? I found this discussion but did not seem to work: http://groups.google.com/group/phonegap/browse_thread/thread/722b0e796baa7fc6
So that is all I have right now.
Before I turn to developing it native if I can't figure it out thought I would ask if anyone has done this before. I can't seem to find any of the phonegap plugins that do something similar.
EDIT: I have got an app that executes Java code as a service. However when it calls sendjavascript it does not work. So is there a way to have the javascript code running in the background as well when an app is closed with phonegap?
Thanks
No, it is not possible to run Javascript code in the background (at least in my opinion) as a service. Phonegap on Android uses an special activity called Droidgap, which hosts a WebView. This browser control executes the JavaScript. This means that JS execution can only handled inside this activity, regardless if it is visible or not.
The code you linked from Google Groups tries to bind a service developed in Java to the DroidGap activity, so the service is NOT written in JS.
You can have some background activity within your JS code inside your child activity derived from the DroidGap activity. For example have a background thread in your activity, have a JS callback function and let the thread call this callback functionality.
If you really need a service you have to go native.
Update:
JS code can only be executed with the Droidgap activity. An activity can have 3 states (based on the Lifecycle of activites):
visible
invisible but still loaded
not loaded
I provided a sample in which I implemented a Phonegap plugin. The plugin allows the activity to register itself to SMS_RECEIVED. When the activies goes out of scope (event onbeforeunload), it deregisters, so only issue 1 is handled.
When you want all 3 issues handled, you have to forward the incoming SMS intent to the activity. When it is not loaded the system will automatically load and activate the activity. But this is not a background service anymore, your app would become visible whenever a SMS is received.
If you don't want this (if you really want a background service), you have to provide a native implementation.
There is this article on how to create a service on Android with Phonegap which gives some good information on your problem.
It's using a great plugin in order to build a background service with phonegap easily. But you can't use JS though
I didn't find a way to make JS to run in the Background. BUT you can pass parameters from Java to JS and vice versa with the plugin...which is pretty useful.
You would still need to rewrite your JS code in Java though.
Unless you do have a specific reason to only want JS to be run? (But there shouldn't be...)
Hope that could be useful to some people visiting this page.
YES, and it is very simple... just install the plugin backgroundJS:
https://build.phonegap.com/plugins/430
It allows you to run javascript on the background and combined with the local notification plugin, you can even send notifications to the user at any time, just keep in mind that doing this will cause the battery to run out faster, also consider that this might create a problem with the iOS policy. good luck!!!
You can try to add plugin cordova-plugin-background-mode
But as author says:
Infinite background tasks are not official supported on most mobile operation systems and thus not compliant with public store vendors. A successful submssion isn't garanteed.
Use the plugin by your own risk!

How to design a remote controller for an android application?

I've written an android application, and I'd like to make it controllable to other machines by sending HTTP request to the device that run my application. I've written a tiny HTTP server and made it start when my application is started. I know I could translate HTTP requests and send messages to various activities to perform UI operations, that need to add listener to all my activities. But in order to make the remote controller code reusable, I hope separate remote controller code from existing application code and thus I need to find a way to make as less as change to the application code to make it be remote controllable.
Could anyone share your ideas?
I dont get what you are asking tbh but in one of application that my friend create, he just implement a mouse pointer which works from any android phone. With that application he can manage to use the android tv.
When he was implementing that app, he took advantage of socket programming and send messages from remote controller, in that situation a phone, to other device and fetch the data in there. In my opinion if you follow such a manner you just dont need to apply so many changes in your other applications. It is all communication in the end.

Categories

Resources