当前位置: 首页>>代码示例>>Java>>正文


Java Browser类代码示例

本文整理汇总了Java中android.provider.Browser的典型用法代码示例。如果您正苦于以下问题:Java Browser类的具体用法?Java Browser怎么用?Java Browser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Browser类属于android.provider包,在下文中一共展示了Browser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startActivity

import android.provider.Browser; //导入依赖的package包/类
@Override
public void startActivity(Intent intent) {
  if (intent.getStringExtra(Browser.EXTRA_APPLICATION_ID) != null) {
    intent.removeExtra(Browser.EXTRA_APPLICATION_ID);
  }

  try {
    super.startActivity(intent);
  } catch (ActivityNotFoundException e) {
    Log.w(TAG, e);
    Toast.makeText(this, R.string.ConversationActivity_there_is_no_app_available_to_handle_this_link_on_your_device, Toast.LENGTH_LONG).show();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:14,代码来源:ConversationActivity.java

示例2: getClickableSpan

import android.provider.Browser; //导入依赖的package包/类
/**
     * 获取超链接字段
     * @return 超链接字符串
     */
    private SpannableString getClickableSpan(String aStr) {
        int startIndex = aStr.indexOf(mAuthorName);
        int endIndex = startIndex + mAuthorName.length();
        SpannableString spannableString = new SpannableString(aStr);
        //设置下划线文字
//        spannableString.setSpan(new UnderlineSpan(), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        //设置文字的单击事件
        spannableString.setSpan(new ClickableSpan() {
            @Override
            public void onClick(View widget) {
                Uri uri = Uri.parse(mExtLink);
                Context context = widget.getContext();
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
                context.startActivity(intent);
            }
        }, startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        //设置文字的前景色
        spannableString.setSpan(new ForegroundColorSpan(ThemeStyle.Accent), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        return spannableString;
    }
 
开发者ID:mainh,项目名称:MainCalendar,代码行数:27,代码来源:AboutActivity.java

示例3: onClick

import android.provider.Browser; //导入依赖的package包/类
@Override
public void onClick(View v) {
    if (mResetCertDecisionsButton == v) {
        nativeResetCertDecisions(mNativeConnectionInfoPopup, mWebContents);
        mDialog.dismiss();
    } else if (mCertificateViewer == v) {
        byte[][] certChain = nativeGetCertificateChain(mWebContents);
        if (certChain == null) {
            // The WebContents may have been destroyed/invalidated. If so,
            // ignore this request.
            return;
        }
        CertificateViewer.showCertificateChain(mContext, certChain);
    } else if (mMoreInfoLink == v) {
        mDialog.dismiss();
        try {
            Intent i = Intent.parseUri(mLinkUrl, Intent.URI_INTENT_SCHEME);
            i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
            i.putExtra(Browser.EXTRA_APPLICATION_ID, mContext.getPackageName());
            mContext.startActivity(i);
        } catch (Exception ex) {
            // Do nothing intentionally.
            Log.w(TAG, "Bad URI %s", mLinkUrl, ex);
        }
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:27,代码来源:ConnectionInfoPopup.java

示例4: openUrl

import android.provider.Browser; //导入依赖的package包/类
private static void openUrl(Activity activity, String url, ComponentName componentName) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.putExtra(Browser.EXTRA_APPLICATION_ID,
            activity.getApplicationContext().getPackageName());
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(IntentHandler.EXTRA_PAGE_TRANSITION_TYPE, PageTransition.AUTO_BOOKMARK);

    if (componentName != null) {
        intent.setComponent(componentName);
    } else {
        // If the bookmark manager is shown in a tab on a phone (rather than in a separate
        // activity) the component name may be null. Send the intent through
        // ChromeLauncherActivity instead to avoid crashing. See crbug.com/615012.
        intent.setClass(activity, ChromeLauncherActivity.class);
    }

    IntentHandler.startActivityForTrustedIntent(intent, activity);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:BookmarkUtils.java

示例5: sendIntent

import android.provider.Browser; //导入依赖的package包/类
/**
 * Sends the intent associated with the quick action if one is available.
 */
public void sendIntent() {
    if (mIntent == null) return;
    mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    // Set the Browser application ID to us in case the user chooses Chrome
    // as the app from the intent picker.
    Context context = getContext();
    mIntent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
    mIntent.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true);
    if (context instanceof ChromeTabbedActivity2) {
        // Set the window ID so the new tab opens in the correct window.
        mIntent.putExtra(IntentHandler.EXTRA_WINDOW_ID, 2);
    }

    IntentUtils.safeStartActivity(mContext, mIntent);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:ContextualSearchQuickActionControl.java

示例6: createBringTabToFrontIntent

import android.provider.Browser; //导入依赖的package包/类
/**
 * @return Intent that tells Chrome to bring an Activity for a particular Tab back to the
 *         foreground, or null if this isn't possible.
 */
@Nullable
public static Intent createBringTabToFrontIntent(int tabId) {
    // Iterate through all {@link CustomTab}s and check whether the given tabId belongs to a
    // {@link CustomTab}. If so, return null as the client app's task cannot be foregrounded.
    List<WeakReference<Activity>> list = ApplicationStatus.getRunningActivities();
    for (WeakReference<Activity> ref : list) {
        Activity activity = ref.get();
        if (activity instanceof CustomTabActivity
                && ((CustomTabActivity) activity).getActivityTab() != null
                && tabId == ((CustomTabActivity) activity).getActivityTab().getId()) {
            return null;
        }
    }

    String packageName = ContextUtils.getApplicationContext().getPackageName();
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, packageName);
    intent.putExtra(TabOpenType.BRING_TAB_TO_FRONT.name(), tabId);
    intent.setPackage(packageName);
    return intent;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:Tab.java

示例7: getExtraHeadersFromIntent

import android.provider.Browser; //导入依赖的package包/类
/**
 * Returns a String (or null) containing the extra headers sent by the intent, if any.
 *
 * This methods skips the referrer header.
 *
 * @param intent The intent containing the bundle extra with the HTTP headers.
 */
public static String getExtraHeadersFromIntent(Intent intent) {
    Bundle bundleExtraHeaders = IntentUtils.safeGetBundleExtra(intent, Browser.EXTRA_HEADERS);
    if (bundleExtraHeaders == null) return null;
    StringBuilder extraHeaders = new StringBuilder();
    Iterator<String> keys = bundleExtraHeaders.keySet().iterator();
    while (keys.hasNext()) {
        String key = keys.next();
        String value = bundleExtraHeaders.getString(key);
        if ("referer".equals(key.toLowerCase(Locale.US))) continue;
        if (extraHeaders.length() != 0) extraHeaders.append("\n");
        extraHeaders.append(key);
        extraHeaders.append(": ");
        extraHeaders.append(value);
    }
    return extraHeaders.length() == 0 ? null : extraHeaders.toString();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:IntentHandler.java

示例8: openExternal

import android.provider.Browser; //导入依赖的package包/类
/**
 * Display a new browser with the specified URL.
 *
 * @param url
 * @return
 */
public String openExternal(String url) {
    try {
        Intent intent = null;
        intent = new Intent(Intent.ACTION_VIEW);
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
        this.cordova.getActivity().startActivity(intent);
        return "";
    } catch (android.content.ActivityNotFoundException e) {
        Log.d(LOG_TAG, "ThemeableBrowser: Error loading url "+url+":"+ e.toString());
        return e.toString();
    }
}
 
开发者ID:archriss,项目名称:inappbrowser-android,代码行数:27,代码来源:ThemeableBrowser.java

示例9: openExternal

import android.provider.Browser; //导入依赖的package包/类
/**
 * Display a new browser with the specified URL.
 *
 * @param url the url to load.
 * @return "" if ok, or error message.
 */
public String openExternal(String url) {
    try {
        Intent intent = null;
        intent = new Intent(Intent.ACTION_VIEW);
        // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
        // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
        Uri uri = Uri.parse(url);
        if ("file".equals(uri.getScheme())) {
            intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri));
        } else {
            intent.setData(uri);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
        this.cordova.getActivity().startActivity(intent);
        return "";
    } catch (android.content.ActivityNotFoundException e) {
        Log.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString());
        return e.toString();
    }
}
 
开发者ID:smukov,项目名称:AvI,代码行数:27,代码来源:InAppBrowser.java

示例10: onClick

import android.provider.Browser; //导入依赖的package包/类
@Override
public void onClick(View widget) {
    try {
        final Uri uri = Uri.parse(getURL());
        final Context context = widget.getContext();
        if (uri.toString().contains("@")) {
            Intent emailIntent = new Intent(Intent.ACTION_SEND);
            emailIntent.putExtra(Intent.EXTRA_EMAIL, uri);
            emailIntent.setType("plain/text");
            context.startActivity(emailIntent);
        } else {
            final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            if (context != null) {
                intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
                context.startActivity(intent);
            }
        }
    } catch (android.content.ActivityNotFoundException ignored) {
        Toast.makeText(widget.getContext(), "No supported email client", Toast.LENGTH_LONG).show();
    } catch (Throwable ex) {

    }
}
 
开发者ID:bvblogic,项目名称:Mediator_Android,代码行数:24,代码来源:SafeURLSpan.java

示例11: onReceive

import android.provider.Browser; //导入依赖的package包/类
@Override public void onReceive(Context context, Intent intent) {
  String url = intent.getDataString();

  if (url != null) {
    Set<String> listOfPackagesThatResolveUri = getNativeAppPackage(context, Uri.parse(url));
    String availableNativeAppPackageName = null;
    if (listOfPackagesThatResolveUri.iterator()
        .hasNext()) {
      availableNativeAppPackageName = listOfPackagesThatResolveUri.iterator()
          .next();
    }

    if (availableNativeAppPackageName != null) {
      Intent launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
      Bundle httpHeaders = new Bundle();
      httpHeaders.putString(REFERER_ATTRIBUTE, REFERER_VALUE);
      launchIntent.putExtra(Browser.EXTRA_HEADERS, httpHeaders);
      launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      context.startActivity(launchIntent);
    } else {
      Toast.makeText(context, "No application to open.", Toast.LENGTH_SHORT)
          .show();
    }
  }
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:26,代码来源:CustomTabNativeReceiver.java

示例12: openExternal

import android.provider.Browser; //导入依赖的package包/类
/**
  * Display a new browser with the specified URL.
  *
  * @param url           The url to load.
  * @param usePhoneGap   Load url in PhoneGap webview
  * @return              "" if ok, or error message.
  */
 public String openExternal(String url) {
     try {
         Intent intent = null;
         intent = new Intent(Intent.ACTION_VIEW);
         // Omitting the MIME type for file: URLs causes "No Activity found to handle Intent".
         // Adding the MIME type to http: URLs causes them to not be handled by the downloader.
         Uri uri = Uri.parse(url);
         if ("file".equals(uri.getScheme())) {
             intent.setDataAndType(uri, webView.getResourceApi().getMimeType(uri));
         } else {
             intent.setData(uri);
         }
intent.putExtra(Browser.EXTRA_APPLICATION_ID, cordova.getActivity().getPackageName());
         this.cordova.getActivity().startActivity(intent);
         return "";
     } catch (android.content.ActivityNotFoundException e) {
         Log.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString());
         return e.toString();
     }
 }
 
开发者ID:GeoThings,项目名称:Clickers,代码行数:28,代码来源:InAppBrowser.java

示例13: onClick

import android.provider.Browser; //导入依赖的package包/类
@Override
public void onClick(View widget) {
    String url = getURL();
    if (url.startsWith("www")) {
        url = "http://" + url;
    }
    Uri uri = Uri.parse(url);
    Context context = widget.getContext();
    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
    intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
    try {
        context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.w("LinkSpan", "Activity was not found for intent, " + intent.toString());
    }
}
 
开发者ID:zzhoujay,项目名称:RichEditor,代码行数:17,代码来源:LinkSpan.java

示例14: getClickableSpan

import android.provider.Browser; //导入依赖的package包/类
/**
 * 设置链接跳转与高亮样式
 *
 * @param url
 * @return
 */
private static ClickableSpan getClickableSpan(final String url) {
    return new ClickableSpan() {
        @Override
        public void onClick(View widget) {
            Uri uri = Uri.parse(url);
            Context context = widget.getContext();
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
            context.startActivity(intent);
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            super.updateDrawState(ds);
            ds.setColor(Color.BLUE);
            ds.setUnderlineText(false);
        }
    };
}
 
开发者ID:woniukeji,项目名称:jianguo,代码行数:26,代码来源:UrlUtils.java

示例15: updateIntent

import android.provider.Browser; //导入依赖的package包/类
/**
 * Updates |mIntentHistory| and |mLastIntentUpdatedTime|. If |intent| comes from chrome and
 * currently |mIsOnEffectiveIntentRedirectChain| is true, that means |intent| was sent from
 * this tab because only the front tab or a new tab can receive an intent from chrome. In that
 * case, |intent| is added to |mIntentHistory|.
 * Otherwise, |mIntentHistory| and |mPreviousResolvers| are cleared, and then |intent| is put
 * into |mIntentHistory|.
 */
public void updateIntent(Intent intent) {
    clear();

    if (mContext == null || intent == null || !Intent.ACTION_VIEW.equals(intent.getAction())) {
        return;
    }

    String chromePackageName = mContext.getPackageName();
    // If an intent is heading explicitly to Chrome, we should stay in Chrome.
    if (TextUtils.equals(chromePackageName, intent.getPackage())
            || TextUtils.equals(chromePackageName, IntentUtils.safeGetStringExtra(intent,
                    Browser.EXTRA_APPLICATION_ID))) {
        mIsInitialIntentHeadingToChrome = true;
    }

    // Copies minimum information to retrieve resolvers.
    mInitialIntent = new Intent(Intent.ACTION_VIEW);
    mInitialIntent.setData(intent.getData());
    if (intent.getCategories() != null) {
        for (String category : intent.getCategories()) {
            mInitialIntent.addCategory(category);
        }
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:33,代码来源:TabRedirectHandler.java


注:本文中的android.provider.Browser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。