Android C2DM - Best way to handle start service intent not found?
<p>I am looking for the best way to notify a user that they need to install a package by handling the possibility of an external package not being found.</p>

<p>In this particular case I am wishing to implement the <code>TODO: if intent not found, notification on need to have GSF</code> in the C2DMMessaging class</p>

<pre><code>public static void register(Context context,
        String senderId) {
    Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT);
    registrationIntent.setPackage(GSF_PACKAGE);
    registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    registrationIntent.putExtra(EXTRA_SENDER, senderId);
    context.startService(registrationIntent);
    // TODO: if intent not found, notification on need to have GSF

}
</code></pre>

<p>I'm thinking that I should look for the error <code>W/ActivityManager(   60): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gsf (has extras) }: not found</code> </p>

<p>But how to trap that error?</p>

<p><strong>UPDATE</strong> - Just found that the call to startService returns a ComponentName instance which is null if the service failed to start so my code now looks like this</p>

<pre><code>ComponentName name = context.startService(registrationIntent);
// TODO: if intent not found, notification on need to have GSF
if(name == null){
    Util.log_debug_message("@@@@ REG INTENT FAILED");
}else{
    Util.log_debug_message("@@@@ REG INTENT SUCCEEDED");
}
</code></pre>

<p>(For anyone looking for this solution Util.log_debug is just a function I created in a util class to call Log.d so just replace this with a call to Log.d)</p>

<p>Which seems to work just fine so I guess I need to  send a broadcast message with an extra to indicate the package needs to be installed. The receiver could then show an alert dialog explaining that the user must install!</p>

<p>What does the user need to install? and how would the user install whatever is needed to be installed?</p>

<p>Thanks in advance for any tips, pointers code snippets and help</p>
