-3
 protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_qrscanner);
        fragment = (BarcodeFragment)getSupportFragmentManager().findFragmentById(R.id.sample);

Is it possible to carry the value that i get from (setScanResultHandler(this)) into another activity?

        fragment.setScanResultHandler(this);
Tan Chong Kai
  • 332
  • 1
  • 4
  • 17

3 Answers3

1

The syntax is like this

For sending data

 String data = getIntent().getExtras().getString("keyName");
 Intent intent = new Intent(ActivityOne.this, ActivityTwo.class);
 intent.putExtra("keyName","value");

For receiving at ActivityTwo

String value= getIntent().getStringExtra("keyName");
Intent intent = getIntent();
Bundle extras = intent.getExtras();
penta
  • 2,536
  • 4
  • 25
  • 50
0

If you just want the Activity context in a fragment, No need to pass anything, Just use getActivity() in your fragment.

If you want to pass data like integer, strings, arrays etc. Create a bundle and put all the values in to bundle like:

Bundle bundle = new Bundle();
bundle.putInt("key",integervalue);
bundle.putString("key",string);
.......

After you put everything into bundle, pass it to fragment like:

fragment.setArguments(bundle);

Then in fragment use getArguments() to get the bundle.

Akshay Bhat 'AB'
  • 2,690
  • 3
  • 20
  • 32
0

Do like below

Intent intent=new Intent(this,SecondActivity.class);
intent.putExtra("ValueName","value");
startActivity(intent);

Assign valueid to ValueName and your value to value

Lakshan
  • 208
  • 1
  • 4
  • 17