// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.util;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
/**
* Utility class for providing platform functionalities.
*/
public class PlatformUtil {
private static final String TAG = "PlatformUtil";
@CalledByNative
private static void launchExternalProtocol(String url) {
Context context = ContextUtils.getApplicationContext();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
try {
context.startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.e(TAG, "cannot find activity to launch %s", url, e);
}
}
}