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);
可能是這有用嗎? (不覆蓋onStartCommand)http://stackoverflow.com/questions/15755785/android-java-intentservice-onhandleintent-does-not-get-called – fersarr
@fersarr沒有骰子,仍然是同樣的問題。 – Fabii