title: How to paste data from previous activity?
body: <p>I'm trying here to make a project, that can scan a barcode (that is done), and after that it's supposed to show some values from a database based on that barcode (product name, address).</p>
  
  <p>I manage to copy the value from the barcode to the clipboard, but then I cannot manage to copy it to the <code>activity_second.xml</code>'s EditText.</p>
  
  <p><img src="https://imgur.com/OS2ywHA" alt=""></p>
  
  <p><strong>AndroidManifest.xml</strong>  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
           &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
               package="br.exemplozxingintegration"
               android:versionCode="1"
               android:versionName="1.0"&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="19" /&gt;
  
      &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.FLASHLIGHT" /&gt;
      &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
      &lt;uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="ScannerBucatarie"
          android:theme="@style/AppTheme"&gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="ScannerBucatarie"
              android:screenOrientation="portrait"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name="com.google.zxing.client.android.CaptureActivity"
              android:configChanges="orientation|keyboardHidden"
              android:label="ZXing ScanBar"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:windowSoftInputMode="stateAlwaysHidden"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.zxing.client.android.SCAN" /&gt;
  
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".SecondActivity"
              android:label="@string/title_activity_second"&gt;&lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>Config.java</strong></p>
  
  <pre><code>package br.exemplozxingintegration;
  
  /**
   * Created by Boghy on 09.02.2016.
   */
  public class Config {
      public static final String DATA_URL = "http://192.168.94.1/test/getData.php?id=";
      public static final String KEY_NAME = "name";
      public static final String KEY_ADDRESS = "address";
      public static final String KEY_VC = "vc";
      public static final String JSON_ARRAY = "result";
  }
  </code></pre>
  
  <p><strong>SecondActivity.java</strong></p>
  
  <pre><code>package br.exemplozxingintegration;
  
  import android.app.ProgressDialog;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.android.volley.RequestQueue;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.StringRequest;
  import com.android.volley.toolbox.Volley;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  public class SecondActivity extends AppCompatActivity implements View.OnClickListener {
  
      private EditText editTextId;
      private Button buttonGet;
      private TextView textViewResult;
  
      private ProgressDialog loading;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          editTextId = (EditText) findViewById(R.id.editTextId);
          buttonGet = (Button) findViewById(R.id.buttonGet);
          textViewResult = (TextView) findViewById(R.id.textViewResult);
  
          buttonGet.setOnClickListener(this);
      }
  
      private void getData() {
          String id = editTextId.getText().toString().trim();
          if (id.equals("")) {
              Toast.makeText(this, "Please enter an id", Toast.LENGTH_LONG).show();
              return;
          }
          loading = ProgressDialog.show(this,"Please wait...","Fetching...",false,false);
  
          String url = Config.DATA_URL+editTextId.getText().toString().trim();
  
          StringRequest stringRequest = new StringRequest(url, new Response.Listener&lt;String&gt;() {
              @Override
              public void onResponse(String response) {
                  loading.dismiss();
                  showJSON(response);
              }
          },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          Toast.makeText(SecondActivity.this,error.getMessage().toString(),Toast.LENGTH_LONG).show();
                      }
                  });
  
          RequestQueue requestQueue = Volley.newRequestQueue(this);
          requestQueue.add(stringRequest);
      }
  
      private void showJSON(String response){
          String name="";
          String address="";
          String vc = "";
          try {
              JSONObject jsonObject = new JSONObject(response);
              JSONArray result = jsonObject.getJSONArray(Config.JSON_ARRAY);
              JSONObject collegeData = result.getJSONObject(0);
              name = collegeData.getString(Config.KEY_NAME);
              address = collegeData.getString(Config.KEY_ADDRESS);
              vc = collegeData.getString(Config.KEY_VC);
          } catch (JSONException e) {
              e.printStackTrace();
          }
          textViewResult.setText("Name:\t"+name+"\nAddress:\t" +address+ "\nVice Chancellor:\t"+ vc);
      }
  
      @Override
      public void onClick(View v) {
          getData();
      }
  }`    AndroidManifet.xml 
   &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="br.exemplozxingintegration"
          android:versionCode="1"
          android:versionName="1.0"&gt;
  
          &lt;uses-sdk
              android:minSdkVersion="8"
              android:targetSdkVersion="19" /&gt;
  
          &lt;uses-permission android:name="android.permission.CAMERA" /&gt;     
          &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
          &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
          &lt;uses-permission android:name="android.permission.FLASHLIGHT" /&gt;
          &lt;uses-permission android:name="android.permission.READ_CONTACTS" /&gt;
          &lt;uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" /&gt;
          &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
          &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt;
          &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  
          &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
          &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  
  
  Config.java
  
      package br.exemplozxingintegration;
  
      /**
       * Created by Boghy on 09.02.2016.
       */
      public class Config {
          public static final String DATA_URL = "http://192.168.94.1/test/getData.php?id=";
          public static final String KEY_NAME = "name";
          public static final String KEY_ADDRESS = "address";
          public static final String KEY_VC = "vc";
          public static final String JSON_ARRAY = "result";
      }
  </code></pre>
  
  <p><strong>activity_second.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
      android:orientation="vertical"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".SecondActivity"&gt;
  
      &lt;LinearLayout
          android:orientation="horizontal"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
          &lt;EditText
              android:id="@+id/txResult"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"/&gt;
          &lt;Button
              android:id="@+id/buttonGet"
              android:text="Get"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
  
      &lt;/LinearLayout&gt;
      &lt;TextView
          android:id="@+id/textViewResult"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/LinearLayout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:weightSum="1"&gt;
  
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:layout_marginTop="10dp"
          android:layout_marginBottom="10dp"
          android:background="#ddd" /&gt;
  
      &lt;Button
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="Scan"
          android:onClick="callZXing"
          android:id="@+id/Button" /&gt;
  
      &lt;View
          android:layout_width="match_parent"
          android:layout_height="1dp"
          android:layout_marginTop="10dp"
          android:layout_marginBottom="10dp"
          android:background="#ddd" /&gt;
  
      &lt;TextView
          android:id="@+id/txResult"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="Rezultat:"
          android:textSize="20sp" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceLarge"
          android:text="Is this the correct code?"
          android:id="@+id/textView"
          android:layout_marginTop="70dp"
          android:layout_gravity="center_horizontal" /&gt;
  
      &lt;Button
          style="@style/CaptureTheme"
          android:layout_width="112dp"
          android:layout_height="68dp"
          android:text="Yes"
          android:layout_marginTop="30dp"
          android:id="@+id/button2"
          android:layout_weight="0.10"
          android:layout_gravity="center_horizontal"
          android:onClick="sendSecond" /&gt;
  
      &lt;Button
          style="@style/CaptureTheme"
          android:layout_width="112dp"
          android:layout_height="68dp"
          android:text="No"
          android:layout_marginTop="10dp"
          android:id="@+id/button1"
          android:layout_weight="0.10"
          android:layout_gravity="center_horizontal"
          android:onClick="callZXing" /&gt;
  
  &lt;/LinearLayout&gt;
   SecondActivity.java
  
  package br.exemplozxingintegration;
  
  import android.app.ProgressDialog;
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.android.volley.RequestQueue;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.StringRequest;
  import com.android.volley.toolbox.Volley;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  public class SecondActivity extends AppCompatActivity implements View.OnClickListener {
  
      private EditText editTextId;
      private Button buttonGet;
      private TextView textViewResult;
  
      private ProgressDialog loading;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          editTextId = (EditText) findViewById(R.id.editTextId);
          buttonGet = (Button) findViewById(R.id.buttonGet);
          textViewResult = (TextView) findViewById(R.id.textViewResult);
  
          buttonGet.setOnClickListener(this);
      }
  
      private void getData() {
          String id = editTextId.getText().toString().trim();
          if (id.equals("")) {
              Toast.makeText(this, "Please enter an id", Toast.LENGTH_LONG).show();
              return;
          }
          loading = ProgressDialog.show(this,"Please wait...","Fetching...",false,false);
  
          String url = Config.DATA_URL+editTextId.getText().toString().trim();
  
          StringRequest stringRequest = new StringRequest(url, new Response.Listener&lt;String&gt;() {
              @Override
              public void onResponse(String response) {
                  loading.dismiss();
                  showJSON(response);
              }
          },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          Toast.makeText(SecondActivity.this,error.getMessage().toString(),Toast.LENGTH_LONG).show();
                      }
                  });
  
          RequestQueue requestQueue = Volley.newRequestQueue(this);
          requestQueue.add(stringRequest);
      }
  
      private void showJSON(String response){
          String name="";
          String address="";
          String vc = "";
          try {
              JSONObject jsonObject = new JSONObject(response);
              JSONArray result = jsonObject.getJSONArray(Config.JSON_ARRAY);
              JSONObject collegeData = result.getJSONObject(0);
              name = collegeData.getString(Config.KEY_NAME);
              address = collegeData.getString(Config.KEY_ADDRESS);
              vc = collegeData.getString(Config.KEY_VC);
          } catch (JSONException e) {
              e.printStackTrace();
          }
          textViewResult.setText("Name:\t"+name+"\nAddress:\t" +address+ "\nVice Chancellor:\t"+ vc);
      }
  
      @Override
      public void onClick(View v) {
          getData();
      }
  }
  </code></pre>