Unable to instantiate service


Last Updated:

  1. PnzrDrgoon

    PnzrDrgoon Member This Topic's Starter

    Joined:
    Jun 11, 2010
    Messages:
    6
    Likes Received:
    0
    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. pzulw

    pzulw New Member

    Joined:
    Mar 31, 2010
    Messages:
    3
    Likes Received:
    0
  3. PnzrDrgoon

    PnzrDrgoon Member This Topic's Starter

    Joined:
    Jun 11, 2010
    Messages:
    6
    Likes Received:
    0
    As it turns out that was exactly the answer I was looking for, thanks!
     

Share This Page

Loading...