-1
protected String doInBackground(String... args) {

        String myres = null;
        String bot_string = args[0] ;
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("question", bot_string));


        JSONObject json = jsonParser.makeHttpRequest(url_pythonwebservice, "GET", params);

        // Check your log cat for JSON reponse
        Log.d("results: ", json.toString());


        try {



            myres = json.getString(TAG_BOTRESPONSE);


        } catch (JSONException e) {
            e.printStackTrace();
        }


        return myres;



    }

 protected void onPostExecute(String file_url) {

        pDialog.dismiss();



        Toast.makeText(getApplicationContext(),file_url , Toast.LENGTH_LONG).show();


        //Get reference to textview above in oncreate method
        //bot.setText(file_url);

    }


 if (file_url == "Navigation"){

            Intent i = new Intent(Voice.this, MapsActivity.class);
            startActivity(i);
        }

Toast is printing.I want to call MapsActivity.class if String file_url == "Navigaion" but this is not working if i put inside the onPostExecute. How can i call MapsActivity.class. This is a voice recognition application.

Smittey
  • 2,475
  • 10
  • 28
  • 35

1 Answers1

0

In Java, you should compare two string as,

if(string1.equals(string2))
 {
   // code block
 }

So, for your example, you should change your code like,

if (file_url.equals("Navigation"))
{
  // more code follows
}
user3289108
  • 770
  • 5
  • 10
  • 29
  • if ("Navigation".equals(file_url) || "navigation".equals(file_url) ) { startActivity(new Intent(Voice.this, MapsActivity.class)); } I put this one but it did not work – Theekshana Vimukthi Nov 13 '15 at 17:12
  • Can you Log the file_url and show me the ouput. I believe you are getting some other value in file_url. – user3289108 Nov 13 '15 at 17:30