Advertisement
Guest User

Codigo

a guest
Apr 12th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. package com.example.ronin.primeiroapp;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.ActionBarActivity;
  5. import android.os.Bundle;
  6. import android.view.Menu;
  7. import android.view.MenuItem;
  8. import android.view.View;
  9. import android.widget.TextView;
  10.  
  11. import com.google.zxing.integration.android.IntentIntegrator;
  12. import com.google.zxing.integration.android.IntentResult;
  13.  
  14.  
  15. public class MainActivity extends ActionBarActivity {
  16.     public static final int REQUEST_CODE = 0;
  17.     private TextView txResult;
  18.     @Override
  19.     protected void onCreate(Bundle savedInstanceState) {
  20.         super.onCreate(savedInstanceState);
  21.         setContentView(R.layout.activity_main);
  22.         txResult = (TextView) findViewById(R.id.textView);
  23.     }
  24.  
  25.     public void callZXing(View view){
  26.         Intent it = new Intent(MainActivity.this, com.google.zxing.client.android.CaptureActivity.class);
  27.         startActivityForResult(it, REQUEST_CODE);
  28.     }
  29.     @Override
  30.     public void onActivityResult(int requestCode, int resultCode, Intent data) {
  31.         if (REQUEST_CODE == requestCode && RESULT_OK == resultCode) {
  32.             txResult.setText("RESULTADO: " + data.getStringExtra("SCAN_RESULT") + " (" + data.getStringExtra("SCAN_FORMAT") + ")");
  33.         }
  34.     }
  35.     @Override
  36.     public boolean onCreateOptionsMenu(Menu menu) {
  37.         // Inflate the menu; this adds items to the action bar if it is present.
  38.         getMenuInflater().inflate(R.menu.menu_main, menu);
  39.         return true;
  40.     }
  41.  
  42.     @Override
  43.     public boolean onOptionsItemSelected(MenuItem item) {
  44.         // Handle action bar item clicks here. The action bar will
  45.         // automatically handle clicks on the Home/Up button, so long
  46.         // as you specify a parent activity in AndroidManifest.xml.
  47.         int id = item.getItemId();
  48.  
  49.         //noinspection SimplifiableIfStatement
  50.         if (id == R.id.action_settings) {
  51.             return true;
  52.         }
  53.  
  54.         return super.onOptionsItemSelected(item);
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement