Start a phone call from a service
<p>I am trying to write an android service, to amongst other things, start a phone call. I have got the service to do other things: listen on network, accept a connection, process text and respond with text. I am now trying to set up a call.</p>

<p>So far I have, the bit to set up the call is it the extra unnecessary {}, when I paste the code in the extra {} in to the activity that starts this service, the call is set up. The only thing I see different is the context. So what am I doing wrong?</p>

<pre><code>public class Service extends android.app.Service {

@Override
public int onStartCommand(Intent intent, int flags, int startId) {  
    {
        android.content.Intent intent2 = 
                new android.content.Intent(
                    android.content.Intent.ACTION_CALL, 
                    android.net.Uri.parse("tel:012345556789"));
        this.startActivity(intent2);
    }       
    return Service.START_NOT_STICKY;
}
</code></pre>

<p>stack</p>

<pre><code>    Thread [&lt;1&gt; main] (Suspended (exception RuntimeException))  
    ActivityThread.handleServiceArgs(ActivityThread$ServiceArgsData) line: 2673 
    ActivityThread.access$1900(ActivityThread, ActivityThread$ServiceArgsData) line: 141    
    ActivityThread$H.handleMessage(Message) line: 1331  
    ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 137 
    ActivityThread.main(String[]) line: 5039    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 511  
    ZygoteInit$MethodAndArgsCaller.run() line: 793  
    ZygoteInit.main(String[]) line: 560 
    NativeStart.main(String[]) line: not available [native method]  
</code></pre>
