微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在Android中将pdf发送到Kindle App时设置作者

如何解决在Android中将pdf发送到Kindle App时设置作者

在我的 Android 应用程序中,我使用以下代码将 pdf 文件发送到 Kindle vi Kindle 应用程序。我没有找到任何关于如何设置作者姓名的文档。另外,标题是使用pdf的文件自动设置的,如何手动设置?

    private void sendToKindleApp(Context context,String path) {
        Intent sharingIntent = getIntent(context,path);
        if (sharingIntent != null) {
            sharingIntent.setPackage("com.amazon.kindle");
            if (sharingIntent.resolveActivity(context.getPackageManager()) != null) {
                context.startActivity(sharingIntent);
                return;
            }
        }
        // show dialog app not installed
    }

    private Intent getIntent(Context context,String path) {
        File requestFile = new File(path);
        Uri fileUri = null;
        try {
            fileUri = FileProvider.getUriForFile(
                    context,BuildConfig.APPLICATION_ID,requestFile);
        } catch (Throwable e) {
            Log.e(TAG,"sendToKindle> The selected file can't be shared: " + requestFile.toString());
        }
        if (fileUri == null) return null;

        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("application/pdf");
        sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        sharingIntent.putExtra(Intent.EXTRA_STREAM,fileUri);
        sharingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        return sharingIntent;
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。