Guest User

Untitled

a guest
Apr 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. //main class
  2. public class MainActivity extends AppCompatActivity {
  3.  
  4. TextView resultview;
  5. Button capture;
  6. static String result_String="Scane is not complete";
  7. int REQUEST_CODE_FOR_QR = 1;
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. setContentView(R.layout.activity_main);
  12. resultview=(TextView)findViewById(R.id.result_show);
  13. capture=(Button)findViewById(R.id.cam_qr);
  14. capture.setOnClickListener(new View.OnClickListener() {
  15. @Override
  16. public void onClick(View view) {
  17.  
  18. Intent intent = new Intent(getApplicationContext(), Result_activity.class);
  19. startActivityForResult(intent, REQUEST_CODE_FOR_QR);
  20. }
  21. });
  22. }
  23. @Override
  24. public void onActivityResult(int requestCode, int resultCode, Intent data){
  25. if(requestCode == REQUEST_CODE_FOR_QR && resultCode == RESULT_OK && data!= null){
  26. result_String=data.getStringExtra(result_String);
  27. resultview.setText(result_String);
  28. }
  29.  
  30. }
  31. }
  32. //result class
  33. Intent resultIntent = new Intent();
  34. resultIntent.putExtra(MainActivity.result_String,rawResult.getText());
  35. setResult(RESULT_OK, resultIntent);
  36. finish();
Add Comment
Please, Sign In to add comment