我试图在Android应用程序上打开一个网页,url sheme有点特殊,它必须在阅读器模式下打开一个URL: about:reader?url=example.com
我是这样做的
Uri intentUri = new Uri.Builder().encodedPath("about:reader")
.appendQueryParameter("url", Uri.encode("example.com"))
.build();
// Try to open in Firefox If available or use default
Intent intent=new Intent(Intent.ACTION_VIEW);
intent.setData(intentUri);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("org.mozilla.firefox");
try {
getApplicationContext().startActivity(intent);
} catch (ActivityNotFoundException ex) {
intent.setPackage(null);
getApplicationContext().startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
logcat的:
E/AndroidRuntime: FATAL EXCEPTION: main
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=about:reader?url=http://example.com
有没有办法实现这个目标?