26 private final ActivityResultLauncher<Intent> launcher =
27 registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(), result -> {
28 setResult(result.getResultCode());
32 @Override
public void onCreate(Bundle savedInstanceState)
34 super.onCreate(savedInstanceState);
35 handleIntent(getIntent());
38 @Override
protected void onNewIntent(Intent intent)
44 private void startSessionWithConnectionReference(String refStr)
47 Bundle bundle =
new Bundle();
48 bundle.putString(SessionActivity.PARAM_CONNECTION_REFERENCE, refStr);
49 Intent sessionIntent =
new Intent(
this, SessionActivity.class);
50 sessionIntent.putExtras(bundle);
52 launcher.launch(sessionIntent);
55 private void editBookmarkWithConnectionReference(String refStr)
57 Bundle bundle =
new Bundle();
58 bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
59 Intent bookmarkIntent =
new Intent(this.getApplicationContext(), BookmarkActivity.class);
60 bookmarkIntent.putExtras(bundle);
61 launcher.launch(bookmarkIntent);
64 private void handleIntent(Intent intent)
67 String action = intent.getAction();
68 if (Intent.ACTION_SEARCH.equals(action))
69 startSessionWithConnectionReference(ConnectionReference.getHostnameReference(
70 intent.getStringExtra(SearchManager.QUERY)));
71 else if (Intent.ACTION_VIEW.equals(action))
72 startSessionWithConnectionReference(intent.getDataString());
73 else if (Intent.ACTION_EDIT.equals(action))
74 editBookmarkWithConnectionReference(intent.getDataString());