Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6980045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:57:50+00:00 2026-05-27T17:57:50+00:00

I am able to invoke the barcode scanner via intents, but when I try

  • 0

I am able to invoke the barcode scanner via intents, but when I try to capture the values returned by the scan based on this, I get the following errors when trying to build the solution.

  • Android.Content.Intent’ does not contain a definition for ‘getStringExtras’ and no extension method ‘getStringExtras’ accepting a first argument of type ‘Android.Content.Intent’ could be found (are you missing a using directive or an assembly reference?)
  • The name ‘RESULT_CANCELED’ does not exist in the current context
  • The name ‘RESULT_OK’ does not exist in the current context

Here is my code for both invoking the scanner and trying to return results.
Click event is in onCreate. onActivityResult is a method in the same.cs, same class, same namespace as the scan.Click event.

    Button scan = (Button)FindViewById(Resource.Id.scan);
        scan.Click += (o, e) =>
        {
            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.SetPackage("com.google.zxing.client.android");
            intent.PutExtra("com.google.zxing.client.android.SCAN.SCAN_MODE", "QR_CODE_MODE");
            StartActivityForResult(intent, 0);
        };

    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");
            }
            else if (resultCode == RESULT_CANCELED)
            {

            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:57:51+00:00Added an answer on May 27, 2026 at 5:57 pm

    The problem here is that your onActivityResult method has not been properly translated from Java to Mono for Android.

    It should look more like:

    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    {
        if (requestCode == 0)
        {
            if (resultCode == Result.Ok)
            {
                String contents = data.GetStringExtra("SCAN_RESULT");
                String format = data.GetStringExtra("SCAN_RESULT_FORMAT");
            }
            else if (resultCode == Result.Canceled)
            {
    
            }
        }
    }
    

    The highlights of the translation are:

    1. Correct signature (and override) for OnActivityResult
    2. Use the Result enumeration
    3. The getStringExtra method in Java is GetStringExtra in C#
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm able to save the captured image from a barcode scanner using this code:
Basically I want to be able to invoke a given command, in this case
I want to be able to invoke an SSIS package at will from a
I'd like to be able to invoke a file download from rails using link
Simple problem (I think): I want to be able to invoke a click method
I have an application A that I would like to be able to invoke
I would like to be able to have hovering over the image invoke the
Application able to record error in OnError, but we are not able to do
I'm able to connect to and read an excel file no problem. But when
I want to be able to capture the exception that is thrown when a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.