Based on JSON data..How to Toast server Status at doInBackground form a Service

前端 未结 2 1007
谎友^
谎友^ 2021-01-17 07:03

I am trying to Show Toast on Server Status

These are my Types of JSONdata from Server

1) {
    \"status\": \"200\",
    \"response\": {
         


        
相关标签:
2条回答
  • 2021-01-17 07:40

    Try it doing this way

    runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    //Your Toast Here
                }
            });
    
    0 讨论(0)
  • 2021-01-17 07:57

    You can easily achieve this with Handler inside your doInBackground method:

            new Handler(Looper.getMainLooper()).post(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(getApplicationContext(), "Your text here", Toast.LENGTH_SHORT).show();
                    //your toast here
                }
            });
    
    0 讨论(0)
提交回复
热议问题