1. Check out our app, Forums for Android! Download and leave feedback here!

Unable to instantiate service

Discussion in 'Application Development' started by PnzrDrgoon, Jun 11, 2010.

  1. PnzrDrgoon

    PnzrDrgoon Member
    Thread Starter
    5

    Jun 11, 2010
    6
    0
    5
    I have a BroadcastReceiver that seems to work, but when it tires to call my IntentService it bombs out saying that it's, "Unable to instantiate service". Below is some of my code:

    Broadcast Receiver:
    Code (Text):
    1.  
    2. public my_receiver extends BroadcastReceiver {
    3.  
    4.     @Override
    5.     public void onReceive(Context context, Intent intent) {
    6.         SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    7.         if(intent.getStringExtra(TelephonyManager.EXTRA_STATE).equals(TelephonyManager.EXTRA_STATE_RINGING) && sPrefs.getBoolean("enabled", false))
    8.         {
    9.             context.startService(new Intent(context,my_intent.class));
    10.         }
    11.     }
    12.    
    13. }
    14.  
    IntentService
    Code (Text):
    1.  
    2. public class my_intent extends IntentService{
    3.    
    4.     public my_intent(String name) {
    5.         super("my_intent");
    6.     }
    7.  
    8.     @Override
    9.     protected void onHandleIntent(Intent intent) {
    10.         android.os.Debug.waitForDebugger();
    11.         Context context = getBaseContext();
    12.         SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    13. ...
    14.  
    Any help would be appreciated!
     

    Advertisement

  2. PnzrDrgoon

    PnzrDrgoon Member
    Thread Starter
    5

    Jun 11, 2010
    6
    0
    5
    As it turns out that was exactly the answer I was looking for, thanks!
     

Share This Page

Loading...