0

I have problem of that type. I have service, in this service I execute my asyncTask, in onPostExecute method I need to startActivity. Try many solutions, doesn't help.

class UpdateReqAsyncTask extends AsyncTask<String, Void, RequestResult> {

        @Override
        protected RequestResult doInBackground(String... params) {
            return performCmd(CMD_GET_STATUS, "");
        }

        @Override
        protected void onPostExecute(RequestResult result) {
            super.onPostExecute(result);
            Intent intent = new Intent(MyService.this, Activity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);

        }
    }

    UpdateReqAsyncTask updateTask = new UpdateReqAsyncTask();
    updateTask.execute();
}
  • 3
    Show us what have you tried. Put some code. – Rohit Arya Apr 12 '16 at 03:27
  • This is not enough information to determine your problem, and should not yet be reopened. What is the problem, exactly? Are you getting errors in your code? Are you getting a runtime `Exception`? Is the `Activity` just not starting? What type of `Service` is `MyService`? Where is `UpdateReqAsyncTask` defined? Is it a separate class? Or is it an inner class of your `Service`? – Mike M. Apr 12 '16 at 04:30
  • @MikeM. thanks for response. I solve problem! In next time try to detailed explain. – Dauren Chapaev Apr 12 '16 at 04:39

0 Answers0