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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:54:01+00:00 2026-06-15T19:54:01+00:00

I Create a GPSservice for my app and I would like to get the

  • 0

I Create a GPSservice for my app and I would like to get the data obtained from the GPSservice for my another list activity and show it. The problem is that it cannot be shown in the list.

the splash code to start the GPSservice:

public class splash extends Activity
{   
    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.splash);


        new Handler().postDelayed(new Runnable() {
            public void run() {
                startService(new Intent("com.example.geotask.gpsservice"));
                    Intent mainIntent = new Intent(splash.this, MainActivity.class);
                    splash.this.startActivity(mainIntent);
                    splash.this.finish();
            }
        }, 1000);
     }

The GPSservice code:

public class GPSservice extends Service
{
    @Override
    public IBinder onBind(Intent intent) {
        // TODO Auto-generated method stub
        return null;
    }
    public  ArrayList<String> position = new ArrayList<String>(); 
    public  ArrayList<Long> time=new ArrayList<Long>();
    public  ArrayList<Integer> lat= new ArrayList<Integer>(); 
    public  ArrayList<Integer> lon= new ArrayList<Integer>(); 
public void onCreate()
{
    super.onCreate();


}
public void onStart(Intent intent, int startID)
{LocationManager locationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
String provider = locationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);
locationManager.requestLocationUpdates(provider, 2000, 10, locationListener);
}
private void additem(Location location){
     String latLongString = "Lat:" + location.getLatitude() + "\nLong:" + location.getLongitude();
     position.add(latLongString);
     long t=location.getTime();
     time.add(t);

}

private void addgeo(Location location){
    int x=(int)location.getLatitude()*1000000;
    int y=(int)location.getLongitude()*1000000;
    lat.add(x);
    lon.add(y);


}


LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {
            additem(location);
                    addgeo(location);
            Intent intent= new Intent("com.example.geotask.gpsdata");
            intent.putIntegerArrayListExtra("lat", (ArrayList<Integer>) lat);
            intent.putIntegerArrayListExtra("lon", (ArrayList<Integer>) lon);
            intent.putStringArrayListExtra("data", (ArrayList<String>) position);
            sendBroadcast(intent);    }



        public void onProviderDisabled(String provider){


        }

        public void onProviderEnabled(String provider) {

        }

        public void onStatusChanged(String provider, int status, Bundle extras) {}
      };
}

The list activity code:

public class list extends Activity{ 
    ArrayList details = new ArrayList();
    private BroadcastReceiver gpsreceiver;
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        IntentFilter intentFilter=new IntentFilter("com.example.geotask.gpsdata");
        intentFilter.addAction("com.example.geotask.gpsdata");
        gpsreceiver=new BroadcastReceiver()
        {
            @Override 
            public void onReceive(Context context, Intent intent)
            {
                List<String> ex=intent.getStringArrayListExtra("data");
                int i=0;
                for(i=0; i<ex.size(); i++)
                {
                    listdetails Detail = new listdetails();
                    Detail.setIcon(R.drawable.ic_launcher);
                    Detail.setPlace(ex.get(i));
                    Detail.setTime("2012.12.2");
                    details.add(Detail);
            }
            }
        };
        this.registerReceiver(gpsreceiver, intentFilter);


        setContentView(R.layout.list); 
        ListView listView; 
        listView = (ListView)findViewById(R.id.listView1);
        customlist Adapter = new customlist(details, this);
        listView.setAdapter(Adapter);


    }
  • 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-15T19:54:03+00:00Added an answer on June 15, 2026 at 7:54 pm

    You need to register your receiver

    registerReceiver(gpsreceiver, intentFilter);
    

    Remember to unregister onDestroy.

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

Sidebar

Related Questions

I would like to provide a service that can be called by other app.
I create an gpsservice, a main activity with two buttons and a list activity.
I have an activity with some TextViews that I update with current values from
I created a service to get data from the /proc/meminfo and the service class
I'm making a plugin that triggers on the create message of a custom activity
I'm having a problem with binding service to an activity. I get playing_service==null. I
Create a new appdomain, setup the assemblyResolve handler and you always get an exception
Create Pex test to test a DLL and hardware controlled by that DLL? I
I am trying to create a SIMPLE plugin, no interface is necessary, that will
Using the TFS API, I am able to create a TFS item, no problem.

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.