1
votes

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");
}
1
@aneroid Thank you for corrections - user6105633
If you do just a tiny bit of research you will see stackoverflow.com/questions/4531396/… also stackoverflow.com/questions/9605913/… - SoroushA
@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. - user6105633
Maybe use a Bundle in your intent? - SoroushA
@SoroushA Have a look please,I have updated my question. Can not get bundle to work. - user6105633

1 Answers

0
votes

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);