简体   繁体   English

如何在Android中隐藏意图

[英]How to hide an intent in android

I am using an activity to show Pdf in android but whenever I use it another application will install to the phone. 我正在使用一个活动在android中显示Pdf,但是每当我使用它时,另一个应用程序就会安装到手机上。 The new app will allow user to use that module to open pdf too, that I dont want. 新的应用程序将允许用户使用该模块来打开pdf,这是我不想要的。 how can i prevent this. 我怎样才能防止这种情况。

i use this code to run the activity but i forgot where i got the resource which was long time ago: 我使用此代码运行活动,但我忘记了很久以前获得资源的位置:

final File file = new File("/sdcard/anyfile.pdf");              
Uri uri = Uri.fromFile(file);
Intent intent = new Intent();
intent.setClassName("com.artifex.mupdf", "com.artifex.mupdf.MuPDFActivity");
intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
startActivity(intent);

When you set this action for intent: 当您将此操作设置为意图时:

intent.setAction(Intent.ACTION_VIEW);

It will try to show all application which have intent filter for this action. 它将尝试显示所有具有此操作的意图过滤器的应用程序。 Remove this and just launch your activity. 删除它,然后开始您的活动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM