我一直在尋找這兩個錯誤的答案,但沒有找到解決方案。
Cannot resolve method 'getDefaultInstance' in 'Session'
'MimeMessage(javax.mail.Session, java.io.InputStream)' in 'javax.mail.internet.MimeMessage' cannot be applied to '(android.se.omapi.Session, android.net.Uri)'
我是否缺少有關使用該軟體包的內容?
public void getBodySignature(Uri uri) throws Exception {
Properties properties = System.getProperties();
Session session = Session.getDefaultInstance(properties, null);
MimeMessage msg = new MimeMessage(session, uri);
SMIMESigned signedMessage;
// multipart/signed message
// two parts- one part for the content that was signed and one part for the actual signature.
if (msg.isMimeType("multipart/signed")) {
signedMessage = new SMIMESigned((MimeMultipart) msg.getContent());
} else if (msg.isMimeType("text/plain") || msg.isMimeType("application/pkcs7-signature")) {
// in this case the content is wrapped in the signature block.
signedMessage = new SMIMESigned(msg);
} else {
throw new IllegalArgumentException("Not a signed message!");
}
uj5u.com熱心網友回復:
您的Session匯入是錯誤的。將匯入替換android.se.omapi.Session為javax.mail.Session。如果這會導致其他問題,因為您需要兩個匯入,那么對于其中一個,您可以使用完全限定名稱。例如:
javax.mail.Session session = javax.mail.Session.getDefaultInstance(properties, null);
另一個問題是Uri爭論。沒有接受or引數MimeMessage的構造函式。我假設您有一個現有的訊息作為檔案并希望從中讀取。您需要將 轉換為. 我在https://developer.android.com/reference/android/net/Uri中找不到任何相關內容。我會看看你是否可以完全擺脫這個論點并將其替換為一個或可以轉換為的東西。URIUriUriInputStreamUriInputStreamInputStream
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/496072.html
