1

I'm using the DVLA database and the JSON result is, eg:

{
"make": "VOLKSWAGEN",
"model": "Tiguan",
"sixMonthRate": "112.75",
"twelveMonthRate": "205.00",
"dateOfFirstRegistration": "23 July 2009",
"yearOfManufacture": "2009",
"cylinderCapacity": "1968cc",
"co2Emissions": "167 g/km",
"fuelType": "DIESEL",
"taxStatus": "Not taxed",
"colour": "SILVER",
"typeApproval": "M1",
"wheelPlan": "2 AXLE RIGID BODY",
"revenueWeight": "Not available",
"taxDetails": "Tax due: 06 February 2015",
"motDetails": "Expires: 23 July 2015",
"taxed": false,
"mot": true
}

My question is, by using android value from editText field

String str = results.getResults().get(0).getPlate();
EditText editText = (EditText)findViewById(R.id.edit_text);
editText.setFilters(new InputFilter[] {new InputFilter.AllCaps()});
editText.setText(str, TextView.BufferType.EDITABLE);

How do I send value "str" as: https://dvlasearch.appspot.com/DvlaSearch?licencePlate=**str**&apikey=DvlaSearchDemoAccount

And how do I display result in JSON or TEXT view in the new window/tab?

I try to use this bundle, BUT "putString" highlight as red and do not get how to send value to another activity. Intent intent = new Intent(MainActivity.this, DVLAresult.class); Bundle bundle = new Bundle(); intent.putString("PlateNumber", editText); intent.putExtras(bundle); startActivity(intent);

This is my second activity

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class DVLAresult extends AppCompatActivity {

        Bundle bundle = getIntent().getExtras();
        String finalPlateNumber = bundle.getString("PlateNumber");
}
  • @aneroid Thank you for corrections –  Mar 23 '16 at 17:20
  • If you do just a tiny bit of research you will see http://stackoverflow.com/questions/4531396/get-value-of-a-edit-text-field also http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android – SoroushA Mar 23 '16 at 18:09
  • @SoroushA But how I can use value from main activity and by using it and pass the JSON display result on second activity, can't get it. –  Mar 23 '16 at 19:04
  • Maybe use a Bundle in your intent? – SoroushA Mar 23 '16 at 19:28
  • @SoroushA Have a look please,I have updated my question. Can not get bundle to work. –  Mar 24 '16 at 01:12

1 Answers1

0

The problem is that you are trying to put your string into the intent not the bundle.

Try this:

Intent intent = new Intent(MainActivity.this, DVLAresult.class);
Bundle bundle = new Bundle();
bundle.putString("PlateNumber", editText); //this line was the problem
intent.putExtras(bundle);
startActivity(intent);
SoroushA
  • 2,043
  • 1
  • 13
  • 29