在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 (将#修改为@)