2014-04-04 58 views
0

我在onHandleIntent(意向意圖)設置一個斷點,它從未達到...任何想法IntentService從未被稱爲

艙單申報

<service android:name=".FeedIntentService" /> 

IntentService:

public class FeedIntentService extends IntentService{ 
    public static final String MSG = "iMSG"; 
    public static final String TAG = "FeedIntentService"; 
    public FeedIntentService() { 
     super("FeedIntentService"); 
    } 

    @Override 
    public void onCreate(){ 
     super.onCreate(); 
    } 

    @Override 
    public void onDestroy(){ 
     super.onDestroy(); 
    } 

    @Override 
    protected void onHandleIntent(Intent intent){ 

     String msg = intent.getStringExtra(MSG); 
     Log.i(TAG, msg); 
     //Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show(); 
    } 
} 

來自MainActivity的服務呼叫:

Intent serviceIntent = new Intent(thisActivity,FeedIntentService.class); 
      serviceIntent.putExtra(FeedIntentService.MSG,"YEEEET"); 
      startService(serviceIntent); 
+0

可能是這有用嗎? (不覆蓋onStartCommand)http://stackoverflow.com/questions/15755785/android-java-intentservice-onhandleintent-does-not-get-called – fersarr

+0

@fersarr沒有骰子,仍然是同樣的問題。 – Fabii

回答

0

的問題是與包名稱:

相反的:

<service android:name=".FeedIntentService"></service> 

我需要:

<service android:name="com.android.service.FeedIntentService"></service>