Open an url in android browser, avoid multiple tabs

前端 未结 2 823
抹茶落季
抹茶落季 2020-12-29 08:31

My project is mostly a web application. Now I have an android app with a home screen widget and would like to open a web page in the built-in browser on some user actions. T

2条回答
  •  生来不讨喜
    2020-12-29 09:13

    Yes, this is possible. Use http://developer.android.com/reference/android/provider/Browser.html#EXTRA_APPLICATION_ID to ensure that the same browser tab is reused for your application. For example:

    Context context = widget.getContext();
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
    

提交回复
热议问题