stopService inside public void onClick
<p>I created a service to start/stop a song, now when I click on "info", service stars correctly but I can't stop it. I should put an intent to stop service within "public void onClick" but I've an error.</p>

<p>this, is the code to stop service: stopService(new Intent(this, SobService.class));</p>

<pre><code>private void Info(){

    startService(new Intent(this, SobService.class));
    LayoutInflater li = LayoutInflater.from(this);
    View view = li.inflate(R.layout.info, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setView(view).create();
    TextView text=(TextView) findViewById(R.id.infoView1);
    builder.setCancelable(false); 
    builder.setPositiveButton("Chiudi", new DialogInterface.OnClickListener()
    {  
           public void onClick(DialogInterface dialog, int id) {  
//stopService(new Intent(this, SobService.class));
               dialog.cancel();   
        }  
        });  
    builder.show();
</code></pre>
