sud*_*rai 3 android google-chrome android-intent google-chrome-app
当 chrome 应用程序被终止时,Google chrome 浏览器会在新选项卡中打开 URL。正在使用以下代码。如果 chrome 应用程序未终止,它将在同一选项卡中打开 URL,否则它将在新选项卡中打开 URL。
String urlString = "https://www.google.com/";
Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse(urlString));
intent1.putExtra(Browser.EXTRA_APPLICATION_ID, "com.android.chrome");
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent1.setPackage("com.android.chrome");
Run Code Online (Sandbox Code Playgroud)
URL 应在 Chrome 中的单个选项卡中打开。
使用EXTRA_APPLICATION_ID来确保您的应用重复使用相同的浏览器选项卡。例如:
http://developer.android.com/reference/android/provider/Browser.html#
例如
Context context = widget.getContext();
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5004 次 |
| 最近记录: |