from ur code what i understand is that u have not defined the class
that implements servive methods(like onBind() etc..)
for ur code to work u need to define one class tha extends Service
class and that return an IBinder object from the onBind() function
(which acts as a proxy to the service object)
this IBinder object is passed to the onServiceConnected() as in ur
code
public void onServiceConnected(ComponentName name,
> IBinder service) {
> Log.e("tag","connected");
>
> }
for beeter understanding check out the sample on the implementation of
the service calss providede in
"android-sdk-windows-1.6_r1\platforms\android-1.5\samples\ApiDemos\src
\com\example\android\apis\app\LocalService.java"
note:you can find this out in ur present working sdk version
On Jan 12, 4:40 am, dane131 <[email protected]> wrote:
> hallo,
>
> I have made an activity that simply binds to a service,here is my
> code :
>
> public class LaunchApp extends Activity {
> /** Called when the activity is first created. */
> Button dial;
>
> �...@override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.main);
>
> Toast.makeText(this, "text", Toast.LENGTH_LONG).show();
> dial=(Button)findViewById(R.id.call_buddy);
> dial.setOnClickListener(new OnClickListener() {
>
> @Override
> public void onClick(View v) {
> launch_app();
>
> }
>
> private void launch_app() {
>
> Intent launch_app=new Intent();
> launch_app.setComponent(new ComponentName
> ("aexp.share.sharedapp1","aexp.share.sharedapp1.Service1"));
>
> bindService(launch_app,mconnection,Context.BIND_AUTO_CREATE);
>
> }
> });
>
> }
> ServiceConnection mconnection=new ServiceConnection(){
>
> @Override
> public void onServiceConnected(ComponentName
> name,
> IBinder service) {
> Log.e("tag","connected");
>
> }
>
> @Override
> public void
> onServiceDisconnected(ComponentName name) {
> Log.e("tag","disconnected");
>
> }};
>
> }
>
> i just want to get a message in the log when my activity connects
> succesfully or disconnects from the service.The above code does not do
> this and the messages are never written to the Log,can you give me
> some fixes for this code?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en