1

我正在使用一个在外部 pdf 阅读器中显示 pdf 文件的 android 应用程序。我注意到,当我使用 adobe reader 时,每次打开 pdf 时,它都会将 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");
    }

}
4

2 回答 2

0

您无法更改用于打开文件的默认应用的 Android 设置。您唯一能做的就是指导用户更改打开 pdf 文件的默认程序。不过,我不会过多关注用户智能......删除这些下载的地图会不会更容易?

于 2013-10-30T10:13:18.913 回答
0

您不能从建议弹出窗口中隐藏应用程序,因为该意图过滤器是在建议弹出窗口中列出的特定应用程序中定义的。

于 2013-10-30T10:02:18.417 回答