R
R
random2015-11-08 09:32:27
Android
random, 2015-11-08 09:32:27

Wait for a response to a request from another application?

Hello, how can I pause a process for a minute (in standby mode)
from another application? If the request is not processed within a minute, the request is deleted.
By request, a record in the database is implied, when a request is sent, a record is written to the database with an empty one column
and an inscription is displayed wait. In another application, all requests are displayed in the form of a listView, where it selects the appropriate required request, after it confirms it,
after confirmation the value is written to empty column. Then in the application where the request was sent, the inscription your request was accepted appears.
And if within a minute the request has not been confirmed, then the request is deleted.
How else can you determine the check that the request is confirmed for that particular client, and only it will display an inscription that the request was accepted?
I use parse.com as a base.
Some code

private class AnswerFromServer extends AsyncTask<Void, Void, Client> {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            upperTextView.setText("Ожидайте...");
        }

        @Override
        protected Client doInBackground(Void... params) {
            final Client clientTemp = new Client();
                ParseQuery<ParseObject> query = ParseQuery.getQuery("test");
                query.getInBackground(client.getobjectId(), new GetCallback<ParseObject>() {
                    @Override
                    public void done(ParseObject parseObject, ParseException e) {
                        if (e == null) {
                            clientTemp.setNumber(parseObject.getInt("number"));
                        } else {
                            Log.d("Error: ", e.getMessage());
                        }
                    }
                });
            return clientTemp;
        }

        @Override
        protected void onPostExecute(Client aVoid) {
            super.onPostExecute(aVoid);
            if (!aVoid.getNumber().equals("")){
                upperTextView.setText("Ваш заказ подтвержден");
            } else {
                upperTextView.setText("Извините, но ваш заказ не принят");
            }
        }
    }

// Вызываю при нажатие кнопки
new AnswerFromServer().execute();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
belozerow, 2015-11-08
@demon123

First, I did not understand anything from the description. Where do you have several applications, where do you have a database?
Secondly, why asynctask, in which you call the background task again?
onPostExecute will always be executed with an empty client.
You don't need asynctask here, just use getInBackground

V
Vladimir Yakushev, 2015-11-10
@VYakushev

Use BroadcastReceiver in both applications to send messages to each other.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question