Java Code Examples for org.chromium.chrome.browser.ChromeActivity#startActivity()

The following examples show how to use org.chromium.chrome.browser.ChromeActivity#startActivity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpdateMenuItemHelper.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Handles a click on the update menu item.
 * @param activity The current {@link ChromeActivity}.
 */
public void onMenuItemClicked(ChromeActivity activity) {
    if (mUpdateUrl == null) return;

    // If the update menu item is showing because it was forced on through about://flags
    // then mLatestVersion may be null.
    if (mLatestVersion != null) {
        PrefServiceBridge.getInstance().setLatestVersionWhenClickedUpdateMenuItem(
                mLatestVersion);
    }

    // Fire an intent to open the URL.
    try {
        Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUpdateUrl));
        activity.startActivity(launchIntent);
        recordItemClickedHistogram(ITEM_CLICKED_INTENT_LAUNCHED);
        PrefServiceBridge.getInstance().setClickedUpdateMenuItem(true);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to launch Activity for: %s", mUpdateUrl);
        recordItemClickedHistogram(ITEM_CLICKED_INTENT_FAILED);
    }
}
 
Example 2
Source File: UpdateMenuItemHelper.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Handles a click on the update menu item.
 * @param activity The current {@link ChromeActivity}.
 */
public void onMenuItemClicked(ChromeActivity activity) {
    if (mUpdateUrl == null) return;

    // If the update menu item is showing because it was forced on through about://flags
    // then mLatestVersion may be null.
    if (mLatestVersion != null) {
        PrefServiceBridge.getInstance().setLatestVersionWhenClickedUpdateMenuItem(
                mLatestVersion);
    }

    // Fire an intent to open the URL.
    try {
        Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUpdateUrl));
        activity.startActivity(launchIntent);
        recordItemClickedHistogram(ITEM_CLICKED_INTENT_LAUNCHED);
        PrefServiceBridge.getInstance().setClickedUpdateMenuItem(true);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to launch Activity for: %s", mUpdateUrl);
        recordItemClickedHistogram(ITEM_CLICKED_INTENT_FAILED);
    }
}
 
Example 3
Source File: BookmarkUtils.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Shows bookmark main UI.
 */
public static void showBookmarkManager(ChromeActivity activity) {
    String url = getFirstUrlToLoad(activity);

    if (activity.getBottomSheet() != null) {
        activity.getBottomSheetContentController().showContentAndOpenSheet(
                R.id.action_bookmarks);
    } else if (DeviceFormFactor.isTablet()) {
        openUrl(activity, url, activity.getComponentName());
    } else {
        Intent intent = new Intent(activity, BookmarkActivity.class);
        intent.setData(Uri.parse(url));
        intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName());
        activity.startActivity(intent);
    }
}
 
Example 4
Source File: UpdateMenuItemHelper.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Handles a click on the update menu item.
 * @param activity The current {@link ChromeActivity}.
 */
public void onMenuItemClicked(ChromeActivity activity) {
    if (mUpdateUrl == null) return;

    // If the update menu item is showing because it was forced on through about://flags
    // then mLatestVersion may be null.
    if (mLatestVersion != null) {
        PrefServiceBridge.getInstance().setLatestVersionWhenClickedUpdateMenuItem(
                mLatestVersion);
    }

    // Fire an intent to open the URL.
    try {
        Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(mUpdateUrl));
        activity.startActivity(launchIntent);
        recordItemClickedHistogram(ITEM_CLICKED_INTENT_LAUNCHED);
        PrefServiceBridge.getInstance().setClickedUpdateMenuItem(true);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "Failed to launch Activity for: %s", mUpdateUrl);
        recordItemClickedHistogram(ITEM_CLICKED_INTENT_FAILED);
    }
}
 
Example 5
Source File: HistoryManagerUtils.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Opens the browsing history manager.
 *
 * @param activity The {@link ChromeActivity} that owns the {@link HistoryManager}.
 * @param tab The {@link Tab} to used to display the native page version of the
 *            {@link HistoryManager}.
 */
public static void showHistoryManager(ChromeActivity activity, Tab tab) {
    Context appContext = ContextUtils.getApplicationContext();
    if (activity.getBottomSheet() != null) {
        activity.getBottomSheetContentController().showContentAndOpenSheet(R.id.action_history);
    } else if (DeviceFormFactor.isTablet()) {
        // History shows up as a tab on tablets.
        LoadUrlParams params = new LoadUrlParams(UrlConstants.NATIVE_HISTORY_URL);
        tab.loadUrl(params);
    } else {
        Intent intent = new Intent();
        intent.setClass(appContext, HistoryActivity.class);
        intent.putExtra(IntentHandler.EXTRA_PARENT_COMPONENT, activity.getComponentName());
        activity.startActivity(intent);
    }
}
 
Example 6
Source File: PhysicalWebShareActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleShareAction(ChromeActivity triggeringActivity) {
    String url = triggeringActivity.getActivityTab().getUrl();

    if (!PhysicalWeb.sharingIsOptedIn()) {
        // This shows an interstitial for the user to opt-in for sending URL to Google.
        Intent intent = new Intent(this, PhysicalWebShareEntryActivity.class);
        intent.putExtra(PhysicalWebShareEntryActivity.SHARING_ENTRY_URL, url);
        triggeringActivity.startActivity(intent);
        return;
    }

    PhysicalWebBroadcastService.startBroadcastService(url);
}