from the code what i understand is you didnot define the class that
implements the service methods(api s like onbind() ..etc)
for this code to work u need to return one Ibinder object from the
onBind()..( which acts as 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 better understanding refer the example given on the service class
implementation in
"<sdk>/platforms/android-<version>/samples/ApiDemos/src/com/example/
android/apis/app/LocalService.java"
note:"<sdk>/platforms/android-<version>" path on the sdk version you
are using till platforms..
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