我正在使用我在外部PDF閱讀器中顯示PDF文件的Android應用程序。 我注意到,當我使用Adobe Reader時,每次打開PDF文件時都會將pdf文件保存在手機的下載文件夾中。如何禁用Adobe Reader將PDF文件保存在下載中?
是否有任何標誌或東西來解決這個問題,使用戶下載地圖不會填滿?
我的代碼:
package com.example.sbny.activities;
import java.io.*;
import java.util.ArrayList;
import java.util.Date;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.ContentProvider;
import android.content.Intent;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Window;
import android.widget.Toast;
import com.example.sbny.R;
import com.example.sbny.data.Coupon;
import com.example.sbny.data.Paper;
import com.example.sbny.database.DatabaseHelper;
import com.example.sbny.database.tables.AdcDB;
import com.example.sbny.database.tables.CouponDB;
import com.example.sbny.utils.FileUtil;
import android.support.v4.content.*;
import com.example.sbny.utils.Logger;
public class LasSollefteabladet extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.las_sollefteabladet);
AdcDB adcDb = new AdcDB(DatabaseHelper.getInstance().getReadableDatabase());
Paper paper = adcDb.getPaper();
File paperFile = FileUtil.getFile(paper.getUrl());
Uri contentUri = null;
try
{
contentUri = FileProvider.getUriForFile(this, "com.example.sbny.fileprovider", paperFile);
}
catch (IllegalArgumentException e) {
Logger.log("kan inte dela filen");
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(contentUri,"application/pdf");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
try
{
getApplicationContext().startActivity(intent);
}
catch (ActivityNotFoundException e)
{
Toast.makeText(LasSollefteabladet.this, "NO Pdf Viewer", Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onRestart()
{
super.onRestart();
Intent nextScreen = new Intent(getApplicationContext(), ManadensSollefteablad.class);
nextScreen.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(nextScreen);
Logger.log("onRestart");
}
}
Okey所以沒有辦法讓Adobe閱讀器不能保存在手機下載的pdf? –
是的。我們不可以。 –