如本帖所示:How to wait for an activity to finish in asynctask
我想等待我从服务启动的活动完成以便返回值。不幸的是,这篇文章没有答案:(我将解释我试图揭露我的问题的清晰看法:
我有这堂课:
public class CertificateConfigurationService {
public boolean configureCertificate(Context context, CertificationConfiguration cert) {
// ... code to create the certificate
Intent intent = KeyChain.createInstallIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(KeyChain.EXTRA_PKCS12, keystore);
intent.putExtra(KeyChain.EXTRA_NAME, cert.getName());
intent.putExtra(KeyChain.EXTRA_CERTIFICATE, credential.getName());
context.startActivity(intent);
}
}
问题是我有一个接收JSON有效负载的ConfigurationService,它可以包含多个要推送到手机的证书。
以下是与调用configure相关的ConfigurationService部分:
... if(payload != null && payload.length() > 0) {
for (int i = 0; i < payload.length(); i++) {
Configuration configuration;
JSONObject currentObject = payload.getJSONObject(i);
configuration = mapper.readValue(currentObject.toString(), Configuration.class);
if (currentObject.getString("typeClass").equals("WLANConfiguration")) {
success = WifiConfigurationService.configureWifi(this.context, (WLANConfiguration) configuration);
} else if (currentObject.getString("typeClass").equals("CertificateConfiguration")) {
success = CertificateConfigurationService.configureCertificate(this.context, (CertificateConfiguration) configuration);
} ...
它适用于一个证书。 但它有2个或更多证书: