导航到一个特定的页面与Android的mupdf库 [英] navigating to a specific page with the mupdf android library

查看:465
本文介绍了导航到一个特定的页面与Android的mupdf库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么会去导航到一个特定的页面与muPDF库?或者是有办法使图书馆不记得我最后一次在该PDF哪一页?

 开放的URI = Uri.parse(路径);
意向意图=新意图(MainActivity.getContext(),MuPDFActivity.class)
intent.setAction(Intent.ACTION_VIEW);
intent.setData(URI);
c.startActivity(意向);
// C是上下文

这是如何我目前正在打开PDF文件。


解决方案

您可以在捆绑包添加页面索引到你的意图,随后被装载在MuPDFActivity该索引并调用mDocView.setDisplayedViewIndex(your_index_from_bundle);这应该做的工作。

类似的东西:

 开放的URI = Uri.parse(路径);
意向意图=新意图(MainActivity.getContext(),MuPDFActivity.class)
intent.setAction(Intent.ACTION_VIEW);
intent.setData(URI);
捆绑额外= intent.getExtras();
extras.putInt(key_page_index,10);
c.startActivity(意向);

然后在MuPDFActivity编辑的onCreate,在的onCreate的末尾添加此code

 意向意图= getIntent();
如果(意向!= NULL){
    捆绑额外= intent.getExtras();
    如果(临时演员!= NULL){
        INT指数= extras.getInt(key_page_index);
        mDocView.setDisplayedViewIndex(索引);
    }
}

How would I go about navigating to a specific page with the muPDF library? Or is there a way to make the library not remember which page I was last on in that pdf?

Uri uri = Uri.parse(path);
Intent intent = new Intent(MainActivity.getContext(), MuPDFActivity.class)
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
c.startActivity(intent);
//c is context

This is how i'm currently opening pdfs.

解决方案

You can add page index in Bundle into your intent, load that index in MuPDFActivity thereafter and call mDocView.setDisplayedViewIndex(your_index_from_bundle); That should do the job.

Something like that:

Uri uri = Uri.parse(path);
Intent intent = new Intent(MainActivity.getContext(), MuPDFActivity.class)
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
Bundle extras = intent.getExtras();
extras.putInt("key_page_index", 10);
c.startActivity(intent);

Then edit onCreate in MuPDFActivity, add this code at the end of the onCreate:

Intent intent = getIntent();
if(intent!=null){
    Bundle extras = intent.getExtras();
    if(extras!=null){
        int index = extras.getInt("key_page_index");
        mDocView.setDisplayedViewIndex(index);
    }
}

这篇关于导航到一个特定的页面与Android的mupdf库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆