[android-developers] Updating a service with data from an activity

2011-06-09 Thread Ab Caballero
I need to send data from an activity to a persistently running GPS
service and I'm not certain how to do this. Below is the code from my
activity and service. ANY help is greatly appreciated.

//%%
// THIS IS THE ACTIVITY
//%%%

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tripinformation);


Button button = (Button)findViewById(R.id.pickup_load);
button.setOnClickListener(mPickupListener);
button = (Button)findViewById(R.id.deliver_load);
button.setOnClickListener(mDeliveryListener);
button = (Button)findViewById(R.id.pickup_delivery);
button.setOnClickListener(mPickupDeliveryListener);
button = (Button)findViewById(R.id.railhead);
button.setOnClickListener(mRailHeadListener);
button = (Button)findViewById(R.id.warehouse);
button.setOnClickListener(mWarehouseListener);
button = (Button)findViewById(R.id.other);
button.setOnClickListener(mOtherLocationListener);
button = (Button)findViewById(R.id.gate);
button.setOnClickListener(mGateListener);
button = (Button)findViewById(R.id.terminal);
button.setOnClickListener(mTerminalListener);
button = (Button)findViewById(R.id.traffic);
button.setOnClickListener(mTrafficListener);
button = (Button)findViewById(R.id.onbreak);
button.setOnClickListener(mBreakListener);
button = (Button)findViewById(R.id.fueling);
button.setOnClickListener(mFuelingListener);
button = (Button)findViewById(R.id.closed);
button.setOnClickListener(mDestinationClosedListener);
button = (Button)findViewById(R.id.closed);
button.setOnClickListener(mPaperworkListener);
button = (Button)findViewById(R.id.paperwork);
button.setOnClickListener(mEquipmentListener);
button = (Button)findViewById(R.id.equipment);
button.setOnClickListener(mOtherIssueListener);
button = (Button)findViewById(R.id.other_issue);
//Return to the LoginActivity
button = (Button)findViewById(R.id.Back);
button.setOnClickListener(new OnClickListener(){
public void onClick(View v){
finish();
}
});
}

//
//  Set the listeners
//  The data from these button presses need to be sent to the
main service
//

private OnClickListener mPickupListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Pickup);
}
};
  private OnClickListener mDeliveryListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Delivery);
}
  };
  private OnClickListener mPickupDeliveryListener = new
OnClickListener() {
public void onClick(View v)
{
getStatus(Pickup/Delivery);
}
};

private OnClickListener mRailHeadListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Railhead);
}
};

private OnClickListener mWarehouseListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Warehouse);
}
};
  private OnClickListener mOtherLocationListener = new
OnClickListener() {
public void onClick(View v)
{
getStatus(OtherLocation);
}
  };
private OnClickListener mGateListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Gate);
}
};
private OnClickListener mTerminalListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Terminal);
}
};
private OnClickListener mTrafficListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Traffic);
}
};
private OnClickListener mBreakListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Break);

}
};
private OnClickListener mFuelingListener = new OnClickListener() {
public void onClick(View v)
{
getStatus(Fueling);
}
};
private OnClickListener mDestinationClosedListener = new
OnClickListener() {
public void onClick(View v)
{
getStatus(DestClosed);
}
};
private OnClickListener mPaperworkListener = new OnClickListener() {
public void onClick(View v)
{

Re: [android-developers] Updating a service with data from an activity

2011-06-09 Thread TreKing
On Thu, Jun 9, 2011 at 9:19 AM, Ab Caballero a...@mac.com wrote:

 I need to send data from an activity to a persistently running GPS service
 and I'm not certain how to do this.


http://developer.android.com/reference/android/app/Service.html#LocalServiceSample

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en