해결책이 그것을 위해 찾을 이일 조사 그래서 아마존 웹 서비스에서 처음 다운로드 PDF 파일에 시도하고 여기에 SD 카드를 연 다음 PDF 파일 내 코드
참고로 저장 후 : - 이 솔루션은 Amazon Web Service의 웹보기에서 PDF보기 전용입니다. 다른 웹 서비스에서 이 코드를 시도 : -
WebView webview=(WebView)findviewbyid(R.id.Webview);
String MyURL= "this is your PDF URL";
String url = "http://docs.google.com/gview?embedded=true&url=" + MyURL;
Log.i(TAG, "Opening PDF: " + url);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
를 -------------------------------- -------------------------------------------------- ------------> 아마존 웹 서비스의 경우이 코드
1>> Download PDF from Amazon WebService
public static void DownloadFile(String fileURL, File directory) {
try {
FileOutputStream f = new FileOutputStream(directory);
URL u = new URL(fileURL);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.connect();
InputStream in = c.getInputStream();
byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = in.read(buffer)) > 0) {
f.write(buffer, 0, len1);
}
f.close();
} catch (Exception e) {
e.printStackTrace();
}
}
2
>>에서 PDF보기 시도하십시오 SD를 카드
public static void showPdfFromSdCard(Context ctx)
{
File file = new File(Environment.getExternalStorageDirectory()+"/pdf/MyPdf.pdf");
PackageManager packageManager = ctx.getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType("application/pdf");
List list = packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
ctx.startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(ctx,
"No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
다운로드 PDF showPdfFromSdCard 메소드를 호출 한 후 . 아마존 웹 서비스에서 PDF를 표시 당신은에서 삭제를 PDF에 대한 SD 카드에서 여기 코드를 PDF 파일을 삭제 쇼 PDF 후
SD 카드
public static void deletePdfFromSdcard(){
File file = new File(Environment.getExternalStorageDirectory()+"/pdf/MyPdf.pdf");
boolean pdfDelete = file.delete();
}
에서
4 >> 전화
deletePdfFromSdcard()
당신은 당신의 스택 트레이스를 게시 할 수 있습니까? –오류나 경고가 표시되지 않습니다. –