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 5846177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:32:23+00:00 2026-05-22T12:32:23+00:00

I created a listview with diff. activity to each items. When the user click

  • 0

I created a listview with diff. activity to each items. When the user click on “clock in” I would like to grab the current time/date and send that data to the webserver in quickest way possible (without going through 2 step process to confirm). This will be for secondActivity class.

UPDATE* I am planning to add a password to the time/date within the phone so the user cant change them. I prefer current time/date within the phone instead of server time because if theres no signal/reception theres no way to clock in. How can I be able to grab the current time/date within the phone?

Customer.java

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Customer extends ListActivity
{
    TextView selection;
    String[] items = { "Start Trip", "Clock in", "Customer Svc", 
            "Independent Inspection", "Pick Up", "Log Out" };

    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        setListAdapter(new ArrayAdapter<String>(
                this, android.R.layout.simple_list_item_1, items));
        selection = (TextView) findViewById(R.id.selection);
    }

private static final int ACTIVITY_0 = 0;
private static final int ACTIVITY_1 = 1;
private static final int ACTIVITY_2 = 2;

@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
    super.onListItemClick(l, v, position, id);
    final Intent intent = new Intent();
    // Set up different intents based on the item clicked: 
    switch (position)
    {
        case ACTIVITY_0:
            intent.setClass(this, com.company.merrill.IntentIntegrator.class);
            break;
        case ACTIVITY_1:
            intent.setClass(this, com.company.merrill.SecondActivity.class);
            break;
        case ACTIVITY_2:
            intent.setClass(this, com.company.merrill.ThirdActivity.class);
            break;
        default:
            break;
    }
    // Pass the item position as the requestCode parameter, so on the `Activity`'s
    // return you can examine it, and determine which activity were you in prior. 
    startActivityForResult(intent, position);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode == RESULT_OK)
    {
        // Perform different actions based on from which activity is
        // the application returning:
        switch (requestCode)
        {
            case ACTIVITY_0:
                // contents contains whatever the code was
                String contents = intent.getStringExtra("SCAN_RESULT");

                // Format contains the type of code i.e. UPC, EAN, QRCode etc...
                String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

                // Handle successful scan. In this example 
                // I just put the results into the TextView
                resultsTxt.setText(format + "\n" + contents);
                break;
            case ACTIVITY_1:
                // TODO: handle the return of the SecondActivity
                break;
            case ACTIVITY_2:
                // TODO: handle the return of the ThirdActivity
                break;
            default:
                break;
        }
    }
    else if (resultCode == RESULT_CANCELED)
    {
        // Handle cancel. If the user presses 'back' 
        // before a code is scanned.
        resultsTxt.setText("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-22T12:32:24+00:00Added an answer on May 22, 2026 at 12:32 pm

    the quickest way would be creating a new thread and opening a connection to the server.

    Take a look to the code:

    new Thread(new Runnable() {
    
        public void run() {
    
            URL url = new URL("http://www.example.com/?data="+System.currentTimeMillis());
    
            HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    
            //if there is no need to read the content then we close the connection
    
            urlConnection.disconnect();
        }
    }).start();
    

    Then on your server-side you’ve to read the $_GET[‘data’] variable if you’re working with php.

    Please consider that this solution is not ok for different timezones. I would probably rely on server-side date.

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

Sidebar

Related Questions

I've created a list and would like to pass the list to another activity
I have created a UserControl that has a ListView in it. The ListView is
I created a program using dev-cpp and wxwidgets which solves a puzzle. The user
I created an Interop user control in VS2005. When the user control is shown
I have created a listview. and there I also did the drag n drop
I recently created a ListView using ListAdapter and applied a static background image behind
Hello all I created a custom listview through my custom adapter.. CustomAdapter adapter =
How can I embed my listview in a layout that I have already created?
We have created a new List View Style that shows thumbnails from a picture
Is it possible to create an integer (or DataTime, etc) column in ListView? It

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.