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

  • SEARCH
  • Home
  • 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 8666347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:42:23+00:00 2026-06-12T17:42:23+00:00

I have an app that scans a qrcode to get client data using the

  • 0

I have an app that scans a qrcode to get client data using the ZXing library. The qrcode holds longitude and latitude data. When the scan takes place i can get the info from the scan result. This is inside the onActivityResult of the ZXing scan. Inside onActivityResult i start a service that find sthe user location, i then compare the results from the service to those held on the qrcode. The results of the scan and the lon and lat values from the service are then stored on a sqlite DB on the phone, this is called a transaction. if the DB is empty then the transaction is stored to the DB. if there is already a transaction in the DB then the service runs twice, even when i have already called stopService. Can any on tell me why.

I’ve logged out that the service is destroyed, is there any reason a service can run after it has been destroyed? thanks.

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        Log.e(TAG, "in onActivityResult from ZXing");
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) {
                Log.e(TAG, "result ok");
                ///////////////////////////////
                tagScanTime  = new DateTime();
                thirtySecsAgo = tagScanTime.minus(30000);
                DateTimeFormatter df = DateTimeFormat.forPattern("dd/MMM/yy h:mmaa");
                String formattedScanTime = df.print(tagScanTime);
                Log.e(TAG, "formatted tag scan time = " + formattedScanTime);
                String formattedthirtysecsAgoTime = df.print(thirtySecsAgo);
                Log.e(TAG, "formatted thity secs ago time = " + formattedthirtysecsAgoTime);


                 contents = intent.getStringExtra("SCAN_RESULT");
                Toast.makeText(this, "scanner has found " + contents,
                        Toast.LENGTH_LONG).show();



                 locationChangereceiver = new BroadcastReceiver() {

                        @Override
                        public void onReceive(Context context, Intent intent) {

                            LocationChangeIntent myIntent = (LocationChangeIntent) intent;
                            lon = myIntent.getLongitude();
                            lat = myIntent.getLaltitude();

                            Log.e( TAG, "values from service =========="+lon+" "+ lat);
                            // stop the service.
                            stopService(new Intent(context, LocationService.class));
                            Log.e( TAG, "just called stopService in nfcscsnActivity");
                            String[] splitPayload = contents.split("@");


                            tagType = splitPayload[0];
                            tagCompany = splitPayload[1];
                            tagPerson = splitPayload[2];
                            tagUserName = splitPayload[3];
                            ////////////////////////////////following values currently not stored to DB
                            tagLongitude = splitPayload[4];
                            tagLatitude = splitPayload[5];

                            Log.e(TAG, "about to compare lon/lat of tag to lon/lat of service");
                            if(tagLongitude.toString().trim().equalsIgnoreCase(String.valueOf(lon))
                                    && tagLatitude.toString().trim().equalsIgnoreCase(String.valueOf(lat))){


                                showToast("carer not in exact position");
                                Log.e(TAG, "carer not in exact position");
                            }else{

                                showToast("carer is in exact position");
                                Log.e(TAG, "carer is in exact position");
                            }


                            processinfo();
                        }
                    };
                    LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(locationChangereceiver,
                            new IntentFilter(LocationChangeIntent.ACTION_LOCATION_CHAHGE));
                    startService(new Intent(this, LocationService.class));










            } else if (resultCode == RESULT_CANCELED) {
                // Handle cancel
                Log.e(TAG, "There's a problem with the scan. Scan result failed");
                Toast.makeText(this, "There's a problem with the scan. Scan result failed",
                        Toast.LENGTH_LONG).show();
            }
        }
    }
  • 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-06-12T17:42:24+00:00Added an answer on June 12, 2026 at 5:42 pm

    solved. I only processed the info after the service had stopped. To do this I checked to see if the service had stopped by using

    if(stopService(new Intent(context, LocationService.class))){
    
    processInfo()
    }
    

    as stopservice returns a boolean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that needs to scan a barcode to get a code
I have a C#/.Net app that is essentially a thick client data collection app.
I have an app that received JSON data from the server. Currently when I
I have an app that allows users to upload large data files and then
I have android app that talks to server and syncs some data int SQLite
I have leveraged the ZXing barcode scanner intent, but it will only scan App
I have an application that scans text from a website in order to get
all. I have an app that scans a picture folder and displays the images
I have an app in which i use zxing barcode scanner to scan qr
have an app that finds your GPS location successfully, but I need to be

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.