简体   繁体   中英

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. The new app will allow user to use that module to open pdf too, that I dont want. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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