anybody help? On 13 Φεβ, 00:44, dane131 <orestis...@gmail.com> wrote: > hallo i have aservicethat provides gps coordinates.Here is the > code : > > package app.suite.gps; > > import android.app.Service; > import android.content.Context; > import android.content.Intent; > import android.location.Location; > import android.location.LocationListener; > import android.location.LocationManager; > import android.os.Bundle; > import android.os.IBinder; > import android.os.RemoteException; > import app.suite.gps.IGps; > > public class Service_impl extendsServiceimplements LocationListener{ > > double lat=37.96568 ; > double lng=23.71382; > > @Override > public IBinder onBind(Intent arg0) { > // TODO Auto-generated method stub > LocationManager lm = > (LocationManager)getSystemService(Context.LOCATION_SERVICE); > lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, > 500.0f, this); > return mBinder; > } > > private final IGps.Stub mBinder = new IGps.Stub() { > > @Override > public double getLat() throws RemoteException { > > return lat; > } > > @Override > public double getLng() throws RemoteException { > > return lng; > } > }; > > public void onLocationChanged(Location location) { > if (location != null) > { > lat = location.getLatitude(); ; > lng = location.getLongitude(); > } > > } > > @Override > public void onProviderDisabled(String arg0) { > // TODO Auto-generated method stub > > } > > @Override > public void onProviderEnabled(String arg0) { > // TODO Auto-generated method stub > > } > > @Override > public void onStatusChanged(String arg0, int arg1, Bundle arg2) { > // TODO Auto-generated method stub > > } > > } > > i want tobindto thisservicefrom another application which uses the > following piece of code : > > package app.suite.client; > > import android.app.Activity; > import android.content.ComponentName; > import android.content.Intent; > import android.content.ServiceConnection; > import android.os.Bundle; > import android.os.IBinder; > import android.os.RemoteException; > import android.util.Log; > import android.view.View; > import android.widget.Button; > import android.widget.TextView; > public class Client extends Activity > { > IGps mservice=null; > > ServiceConnection conn=new ServiceConnection() { > > @Override > public void onServiceDisconnected(ComponentName name) { > Log.e("TAG","DISCONNECTED"); > > } > > @Override > public void onServiceConnected(ComponentName name, > IBinderservice) > { > > mservice=IGps.Stub.asInterface(service); > try > { > double a=mservice.getLat(); > String a_str=Double.toString(a); > Log.e("TAG",a_str); > } > catch(RemoteException e) > { > > } > > } > }; > public void onCreate(Bundle icicle) > { > super.onCreate(icicle); > setContentView(R.layout.main); > > Intentservice= new Intent(); > service.setComponent(new > ComponentName("app.suite.gps","app.suite.gps.Service_impl")); > bindService(service, conn, BIND_AUTO_CREATE); > > } > } > > When i run the code i get the security exception "unabletobindtoservice" > > (I have included the IGps.aidl file in both applications and generated > the interfaces)
-- 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