I’ m designing Android client for a web site. So there are a lot of different network operations i have to implement. For a example user authorization or searching on a server. To do this I must send JSON request to REST web server with some parameters and URL. So I must pass not only String parameters but some data structure (LinkedHashMap for instance). The problem i don’t know the most correct way. By far I did next:
protected Boolean doInBackground(Object... param). And then convert param[0],param [1] to different type. I think it is a bad way.- Using javatuples library for this purpose:
protected Void doInBackground(Pair<String, LinkedHashMap<String, Object>>... params)
It seems too complex and redundant code. And the most important I must add
@SuppressWarnings("unchecked")
or I got a type safety warning.
So may be some experts can help me with this and advice the most correct and efficient way.
You could have your own constructor for the Asynctask and store these as fields which you could use in doinBackground
and then