开发者

How to control list of Apps shown when starting Intent?

I want to start an Intent to open/view a PDF I have just created.

Intent intent = new Intent(Intent.ACTION_VIEW);开发者_开发技巧
intent.setDataAndType(path, "application/pdf");
intent.setData(path);
this.startActivity(intent);

This pops up a "Select an action" dialog with two options:

  • Android System
  • Browser

If I choose Android System, THEN it'll give me another dialog box which show the list of apps capable of showing a PDF.

How do I skip that first dialog and jump right to dialog with the list of apps?


Try getting rid of the setData() call. It is redundant, in that you are setting the Uri in setDataAndType(), and you are wiping out your MIME type by calling setData() after setDataAndType().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜