0

I'm trying out the new Chrome custom tabs and want to add a custom menu item to bookmark the displayed page url. I create a new pending intent to launch the bookmark activity but I cannot find a way to pass the current page url to the bookmark activity. Is this possible or not?

This is how I create the menu item:

private void prepareMenuItems(CustomTabUiBuilder uiBuilder) {
    Intent menuIntent = new Intent();
    menuIntent.setClass(getApplicationContext(), this.getClass());
    Bundle menuBundle = ActivityOptions.makeCustomAnimation(this, android.R.anim.slide_in_left,
            android.R.anim.slide_out_right).toBundle();
    PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, menuIntent, 0,
            menuBundle);
    uiBuilder.addMenuItem("Bookmark page", pi);
    menuIntent.setClass(getApplicationContext(), BookmarkActivity.class);
}
Magnus G
  • 111
  • 4

1 Answers1

0

EDIT: This was changed since launch. Now, it's possible to retrieve the URL. To handle the URL on the BroadcastReceiver do like this:

@Override
public void onReceive(Context context, Intent intent) {
    String url = intent.getDataString();
    if (url != null) {
        String toastText =
                getToastText(context, intent.getIntExtra(KEY_ACTION_SOURCE, -1), url);
        Toast.makeText(context, toastText, Toast.LENGTH_SHORT).show();
    }
}
andreban
  • 4,621
  • 1
  • 20
  • 49
  • That is what I want to do, to bookmark (or share) the new url that the user navigated to. I cannot find a way to pass the new url with the pending intent. – Magnus G Sep 08 '15 at 10:23