* 전자 메일을 읽을 수있는 응용 프로그램을 작성 중입니다. 나는 textview/edittext를 사용하여 메일을 표시하고 있습니다. 지금 나는 전자 메일 내용을 문자열로 가져 와서 표시 할 수 있습니다. 하지만 html 콘텐츠와 이미지가 포함 된 이메일을 표시하는 데 가장 좋은 방법은 무엇입니까 ?? 도와주세요. 고마워요 :) 편집 : 나는 S.O.의 제안대로 webview를 사용했습니다. 친구들 (감사합니다 @ Andro Selva, @CFlex). 하지만 문제가 발생했습니다. 전자 메일의 본문을 두 번 표시합니다. :( 일단 텍스트/일반 다시 텍스트/HTML로. 내가 웹보기를로드하는 코드를 다음과 같은 노력했다.으로안드로이드에 이미지 및 HTML 콘텐츠를 표시하는 데 가장 좋은 방법
여기webViewBody.loadData(details[3], "text/html", "UTF-8");
//webViewBody.loadDataWithBaseURL(null, details[3] , "text/html", "utf-8", null);
[3] 이메일 내용입니다. 내가 무엇을 생각 자세한 사항 여기에 실종!? :(저를 도와주세요
편집 :.. 나는 아래의 이메일 내용을 표시하기위한 메시지 내용을 얻기 위해 사용했다 내가 추가 한 코드를
public void getContent(Message msg)
{
try
{
Object o = msg.getContent();
if (o instanceof String)
{
if(((String) o).equalsIgnoreCase(""))
{
}
else
{
messageBody = (String)o+"STRING!!";
}
}
else if (o instanceof Multipart)
{
Multipart mp = (Multipart)o;
int count3 = mp.getCount();
for (int j = 0; j < count3-1; j++)
{
// Part are numbered starting at 0
BodyPart b = mp.getBodyPart(j);
Object o2 = b.getContent();
if (o2 instanceof String)
{
if(((String) o).equalsIgnoreCase(""))
{
}
else
{
messageBody = (String)o2+"MULTIPART!!";
}
}
} //End of for
}
else if (o instanceof InputStream)
{
//System.out.println("**This is an InputStream message**");
InputStream is = (InputStream)o;
// Assumes character content (not binary images)
//messageBody = convertStreamToString(is)+"INPUT STREAM!!";
int c;
while ((c = is.read()) != -1)
{
messageBody = convertToString(is)+"INPUT STREAM!!";
System.out.println(messageBody);
}
}
}
catch (Exception ex)
{
System.out.println("Exception arise at get Content");
ex.printStackTrace();
}
//TODO TEST CODES
try
{
String contentType = msg.getContentType();
// System.out.println("Content Type : " + contentType);
Multipart mp = (Multipart) msg.getContent();
int count = mp.getCount();
for (int i = 0; i < count; i++)
{
dumpPart(mp.getBodyPart(i));
}
}
catch (Exception ex)
{
System.out.println("Exception arise at get Content");
ex.printStackTrace();
}
}
public String convertToString(InputStream inputStream)
{
StringBuffer string = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
try
{
while ((line = reader.readLine()) != null)
{
string.append(line + "\n");
}
}
catch (IOException e)
{
}
return string.toString();
}
컨트롤은 항상 "else if (o instanceof InputStream)"조건으로 이동합니다. 그래서 그것의 스트리밍 이메일은 항상 완전한 전자 메일 컨텐츠를 표시합니다. 내가 여기서 무엇을 놓치고 있니?
어쩌면 webview? 동일한 효과가 있지만 다른보기보다 html을 더 효과적으로 관리 할 수 있습니다. –
답장을 보내 주셔서 감사합니다. 여기에서 다시 시도해 보겠습니다. – Aadi
내 주요 질문을 업데이트했습니다. 확인하고 도와주세요. – Aadi