Do you have any code that binds to this service?
2011/6/20 Boozel <[email protected]>
> Hi
> I have a toggle button which i use to start and stop a service
> When i press the button the service starts fine but i cant seem to stop it.
> The boolean a in my code below return true but the service keeps running.
> What am i doing wrong? any help would be great.
> Thanks in advance
>
> toggle = (ToggleButton) findViewById(R.id.toggle);
> toggle.setOnClickListener(new OnClickListener() {
> public void onClick(View v) {
> boolean checked = toggle.isChecked();
> SharedPreferences.Editor editor = sharedPreferences.edit();
> editor.putBoolean("toggle", checked);
> editor.commit();
> Intent toggleIntent = new Intent(MyActivity.this,
> MyService.class);
> if (checked) {
>
> try
> {ComponentName a = startService(toggleIntent);
> Log.w(TAG,"toggle Enabled: "+a.toString());}
> catch (Exception e)
> {Log.i(TAG,"Cannot Start toggleService:
> "+e.getMessage());
> Toast.makeText(getApplicationContext(), "Cannot Start
> toggleService:\n" +
> e.getMessage(), Toast.LENGTH_LONG).show();
> }
> } else {
>
> try{boolean a = stopService(toggleMapIntent);
> Log.w(TAG,"toggle Disabled: "+a);}
> catch (Exception e)
> {Log.i(TAG,"Cannot Stop toggleService:
> "+e.getMessage());
> Toast.makeText(getApplicationContext(), "Cannot Stop
> toggleService:\n" +
> e.getMessage(), Toast.LENGTH_LONG).show();}
> }
> }
> });
>
> --
> 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
--
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