如果在 Android 中获取空值,如何从 JSON 解析 Toast "No Data Found"

How to Toast "No Data Found" From JSON parsing if getting null value in Android

如果我得到 null 值,我正在从 URL 解析 JSON 值,所以我想要 Toast "data not found"
我的代码在这里

    @Override
    protected List<Details> doInBackground(String... params) {
        List<Details> result = new ArrayList<Details>();
        ServiceHandler serviceHandler=new ServiceHandler(TrainshwstnActivity.this);
            String u = new String(params[0]);
            String JsonStr=serviceHandler.makeServiceCall(u, ServiceHandler.GET);
            Log.d("Response: ", "> " + JsonStr);
               if (JsonStr != null) {
                    try {                       
                    JSONArray arr = new JSONArray(JsonStr);
                    for (int i=0; i < arr.length(); i++) {
                        result.add(convertContact(arr.getJSONObject(i)));
                    }

                    return result;
                }
                catch(Throwable t) {
                    t.printStackTrace();
                }
                return null;
            }
        return result;
        }

doInbackground代码后添加代码:

protected void onPostExecute(String result) {
     if(result == null){
     Toast.makeText(getApplicationContext(),"No data found", Toast.LENGTH_LONG).show();
     }
 }