@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_qrreciever); } @Override protected void onStart (){ super.onStart(); try{ //call zxing qr scan Intent GetEan = new Intent(Intent.ACTION_SEND); GetEan.setType("com.google.zxing.client.android.SCAN"); GetEan.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); GetEan.putExtra("SCAN_MODE", "PRODUCT_MODE"); startActivityForResult(GetEan, 0); } catch (Exception e) { //Prompt asking for permission to go to store FrameLayout StorePrompt = (FrameLayout) findViewById(android.R.id.custom); //StorePrompt.addView(myView, new WindowManager.LayoutParams(MATCH_PARENT, WRAP_CONTENT)); Uri marketUri = Uri.parse("market://details?id=com.google.zxing.client.android"); Intent marketIntent = new Intent(Intent.ACTION_VIEW, marketUri); startActivity(marketIntent); } } @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_qrreciever, menu); return true; } @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == 0) { if (resultCode == RESULT_OK) { String contents = intent.getStringExtra("SCAN_RESULT"); String format = intent.getStringExtra("SCAN_RESULT_FORMAT"); // Handle successful scan } else if (resultCode == RESULT_CANCELED) { // Handle cancel Log.i("App", "Scan unsuccessful"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)