Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.ronin.primeiroapp;
- import android.content.Intent;
- import android.support.v7.app.ActionBarActivity;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.TextView;
- import com.google.zxing.integration.android.IntentIntegrator;
- import com.google.zxing.integration.android.IntentResult;
- public class MainActivity extends ActionBarActivity {
- public static final int REQUEST_CODE = 0;
- private TextView txResult;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- txResult = (TextView) findViewById(R.id.textView);
- }
- public void callZXing(View view){
- Intent it = new Intent(MainActivity.this, com.google.zxing.client.android.CaptureActivity.class);
- startActivityForResult(it, REQUEST_CODE);
- }
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (REQUEST_CODE == requestCode && RESULT_OK == resultCode) {
- txResult.setText("RESULTADO: " + data.getStringExtra("SCAN_RESULT") + " (" + data.getStringExtra("SCAN_FORMAT") + ")");
- }
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement