creating Services for location bases application

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


Sponsored Links
 i,

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.app.Service;
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
serviceHandler)
{
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);
Log.d(LOG_TAG,"onstart");

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

TelephonyManager tm = (TelephonyManager)getSystemService
(Context.TELEPHONY_SERVICE);
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:" +
latLongString);

Toast.makeText(this,"Location:"+latLongString ,
Toast.LENGTH_SHORT);
}
else
{
latLongString ="No Location found";
}



BackgroundServiceTask bst = new BackgroundServiceTask
(COUNTDOWN_LIMIT, COUNTDOWN_INTERVAL, serviceHandler);
serviceHandler.postDelayed(bst,COUNTDOWN_INTERVAL);
stopSelf();

}

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


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

}


Broadcast receiver



Other Threads

1. Vertical TextView

Can I somehow make my TextView to be vertical - it should look like
normal TextView rotated 90 degrees. I want this because at the bottom
of the screen I have a SlidingDrawer widget with a TextView label and
when the screen orientation changes to landscape I want to display the
SlidingDrawer at the right edge of the screen - so it will be rotated
90 degrees.
--~--~---------~--~----~------------~-------~--~----~

2. Minta tutorial nge root htc magic bwt nubie dong master.

Hanya sekedar mengumpan aja bro, harapannya RR lainnya akan mengkoreksi & 
menambahkannya....:).
Siap bro akan dikabar-kabari, mudah2an kelar sesuai dg harapan sebab harus 
multitasking juga nih kerjakan yg lain & ditarik kiri kanan. Mudah2an tidak 
keburu hang & kepanasan processornya....hahahahahahaha.
  ----- Original Message ----- 
  From: Bayu Wicaksono 
  To: id-android@googlegroups.com 
  Sent: Tuesday, October 13, 2009 1:51 PM
  Subject: [id-android] Re: Minta tutorial nge root htc magic bwt nubie dong 
master.


  wah akhirnya ada yg mo nulis di id-android wiki... yg dream juga baru jadi 
sebagian euy... maap ya semua... 
  yg Magic klo udah jadi dikabarin dimari ya bos :D


  2009/10/13 Subanindiyo Ardi <subanindiyo.a...@gmail.com>


    Sabar boss, mudah2an hari ini sudah dapat dilihat di wiki id-android kalau
    tidak ada kerjaan dadakan dari boss disini.
    Masih sedang ketak-ketik disana. Baru sekali gunakan wiki, rada2 lelet
    jadinya....:).


    ----- Original Message -----
    From: "logay pektay" <logay.pek...@gmail.com>
    To: <id-android@googlegroups.com>
    Sent: Tuesday, October 13, 2009 1:41 PM
    Subject: [id-android] Minta tutorial nge root htc magic bwt nubie dong
    master.


    >
    > Om,htc magic sy 100% msh perawan,seri 32a.
    >
    > Nah pgn di root,tp ga tau cara nya.
    >
    > Kl ada yg indonesian language aja,bkn ga bs bhs.ing,tp tkt ada cara
    > ato kata2 yg salah diartiin.
    >
    > Yg mudah n aman nya aja.hee
    >
    > Mksh om om semua.
    >
    > Baru2 pake htc magic nh.
    >
    > My gadget:
    > 1. Htc magic
    > 2. Blackberry storm 9530
    > 3. Asus m930
    > 4. Htc sprint mogul 6800vx
    > 5. Iphone 3G
    >
    > --
    > Sent from my mobile device
    >
    > >







  


--~--~---------~--~----~------------~-------~--~----~
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group, please visit the following page:
 

3. Why does getPadding() of NinePatchDrawable throw a NullPointerException?

4. barcodeScanner

5. Help! Trying to get Basic Auth working with WebView. setHttpAuthUsernamePassword?

6. Properly Disconnecting the "Network" on the Emulator

7. where is the correct place to put libopencorehw?