0
如果我做的:sendOrderedBroadcast - 哪個線程是響應接收器運行?
sendOrderedBroadcast(intent, null, new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if(getResultCode() == Activity.RESULT_OK) {
Log.d("LoginActivity", "OK");
} else {
Log.e("LoginActivity", "Fail!");
}
}
}, null, Activity.RESULT_CANCELED, null, null);
哪個線程是onReceive()
方法運行?在發送線程或在UI線程上?
來自文檔:'scheduler' \t用來調度resultReceiver回調的自定義Handler;如果爲null,它將被安排在上下文的主線程中 – pskink
因此,這意味着在UI線程上,對不對? – JohnyTex
只需使用'Log.d'和'Thread.currentThread()' – pskink