creating Services for location bases application

by Goldmember » Tue, 27 Jan 2009 04:27:46 GMT

Sponsored Links

I am new to android Development.
I have created a location based application which runs in the
Background. I dont get any errors but when i try to check it out using
emulator. I get a message saying that the applicataion has stopped
unexpectedly, Pls try again.
Can some one help me out with this problem.

Service File:

package com.Location.LBS;

import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import android.widget.Toast;
import android.os.Handler;

class BackgroundServiceTask implements Runnable{

private static final String LOG_TAG="BackgroundService";
private Handler serviceHandler;
private int countDown = 0;
private long interval= 0L;

public BackgroundServiceTask(int countDown, long interval, Handler
this.countDown = countDown;
this.interval = interval;
this.serviceHandler = serviceHandler;

public void run()
Log.d(LOG_TAG,"Counter:"+ countDown);
if(--countDown > 0)
serviceHandler.postDelayed(this, interval);


public class MyService extends Service {

private static final String LOG_TAG ="Background Service";
private Handler serviceHandler = new Handler();
private static final int COUNTDOWN_LIMIT = 10;
private static final long COUNTDOWN_INTERVAL = 3*1000L;

protected void onStart(int startId,Bundle arguments)
super.onStart(null , startId);

GsmCellLocation location;
int cellID, lac;
final String latLongString;

TelephonyManager tm = (TelephonyManager)getSystemService
location = (GsmCellLocation) tm.getCellLocation();

if(location != null)
cellID =location.getCid();
lac = location.getLac();

latLongString="CellID:"+ 2675+"\n Lac:"+8894;

Log.i(getClass().getSimpleName(), "Data From
Location:" +

Toast.makeText(this,"Location:"+latLongString ,
latLongString ="No Location found";

BackgroundServiceTask bst = new BackgroundServiceTask


public void onDestroy()
Log.d(LOG_TAG, "onDestory");

public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;


Broadcast receiver

Other Threads

1. Cookies

How does one go about setting a cookie?

I have an website that sends mp3's to clients, but the request must have a
cookie attached to it. How would I go about setting a cookie for a
MediaPlayer URL request? Is that even possible?


2. Help needed on porting Flixel Framework to Android. Current issue: switch from canvas draw to opengl es

Hello Android Devs,

WingEraser (its how I know him) has been porting Flixel to Android for a 

What is flixel? An actionscript 3.0 game framework. Its very well organized 
and have a lot of good stuff into it. Collisions, particles, nice use of 
bitmaps to tiles and sprite animations.
If someone is curious about flixel, its homepage has some games:

Abour the porting to android: Theres a lot of good done, but one issue is 
giving certain trouble: to convert the framework render pipeline, from 
canvas draw to opengl es.

Theres someone up to work on that? Im lerarning what I can, but Im a little 
new on Java, Android and OpenGL.

Ah, the last threads about flixel-android:

And the project page:

Thanks, Zimbres.


3. Not able to write a file completely with fileinputstream and fileoutputstream?

4. Starting An Android App From An Url

5. TCP client force close

6. Ngecharge dari jam 1 siang sampai jam 5 sore baru 81%

7. Dear friend: