當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.setSelector方法代碼示例

本文整理匯總了Java中android.content.Intent.setSelector方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.setSelector方法的具體用法?Java Intent.setSelector怎麽用?Java Intent.setSelector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.setSelector方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.content.Intent; //導入方法依賴的package包/類
protected void onCreate(Bundle savedInstanceState) {
    try {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        if (intent != null) {
            Intent forwordIntent = getForwarIntent();
            if (forwordIntent != null) {
                forwordIntent.addFlags(268435456);
                forwordIntent.putExtras(intent);
                if (VERSION.SDK_INT >= 15) {
                    forwordIntent.setSelector(null);
                }
                if (ApkManager.getInstance().isConnected()) {
                    if (isPlugin(forwordIntent)) {
                        startActivity(forwordIntent);
                    }
                    finish();
                    return;
                }
                waitAndStart(forwordIntent);
                return;
            }
            finish();
            return;
        }
        finish();
    } catch (Exception e) {
        e.printStackTrace();
        finish();
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:32,代碼來源:ShortcutProxyActivity.java

示例2: onCreate

import android.content.Intent; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    try {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();

        if (intent != null) {
            Intent forwordIntent = getForwarIntent();
            if (forwordIntent != null) {
                forwordIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                forwordIntent.putExtras(intent);
                //安全審核問題
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
                    forwordIntent.setSelector(null);
                }
                if (PluginManager.getInstance().isConnected()) {
                    if (isPlugin(forwordIntent)) {
                        execStartForwordIntent(forwordIntent);
                    }
                    finish();
                } else {
                    waitAndStart(forwordIntent);
                }
            } else {
                finish();
            }
        } else {
            finish();
        }
    } catch (Exception e) {
        e.printStackTrace();
        finish();
    }
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:35,代碼來源:ShortcutProxyActivity.java

示例3: shouldOverrideUrlLoading

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Give the host application a chance to take over the control when a new url
 * is about to be loaded in the current WebView.
 *
 * @param view          The WebView that is initiating the callback.
 * @param url           The url to be loaded.
 * @return              true to override, false for default behavior
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
boolean shouldOverrideUrlLoading(WebView view, String url) {
    // Give plugins the chance to handle the url
    if (this.appView.pluginManager.onOverrideUrlLoading(url)) {
        // Do nothing other than what the plugins wanted.
        // If any returned true, then the request was handled.
        return true;
    }
    else if(url.startsWith("file://") | url.startsWith("data:"))
    {
        //This directory on WebKit/Blink based webviews contains SQLite databases!
        //DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING!
        return url.contains("app_webview");
    }
    else if (appView.getWhitelist().isUrlWhiteListed(url)) {
        // Allow internal navigation
        return false;
    }
    else if (appView.getExternalWhitelist().isUrlWhiteListed(url))
    {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setComponent(null);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
                intent.setSelector(null);
            }
            this.cordova.getActivity().startActivity(intent);
            return true;
        } catch (android.content.ActivityNotFoundException e) {
            LOG.e(TAG, "Error loading url " + url, e);
        }
    }
    // Intercept the request and do nothing with it -- block it
    return true;
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:46,代碼來源:CordovaUriHelper.java

示例4: onDownloadStart

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Notify the host application a download should be done, or that the data
 * should be streamed if a streaming viewer is available.
 *
 * @param context            The context in which the download was requested.
 * @param url                The full url to the content that should be downloaded
 * @param userAgent          User agent of the downloading application.
 * @param contentDisposition Content-disposition http header, if present.
 * @param mimetype           The mimetype of the content reported by the server
 * @param contentSize        The size of the content
 */
public void onDownloadStart(@NonNull Activity context, @NonNull PreferenceManager manager, String url, String userAgent,
                            @Nullable String contentDisposition, String mimetype, String contentSize) {

    Log.d(TAG, "DOWNLOAD: Trying to download from URL: " + url);
    Log.d(TAG, "DOWNLOAD: Content disposition: " + contentDisposition);
    Log.d(TAG, "DOWNLOAD: Mimetype: " + mimetype);
    Log.d(TAG, "DOWNLOAD: User agent: " + userAgent);

    // if we're dealing wih A/V content that's not explicitly marked
    // for download, check if it's streamable.
    if (contentDisposition == null
        || !contentDisposition.regionMatches(true, 0, "attachment", 0, 10)) {
        // query the package manager to see if there's a registered handler
        // that matches.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse(url), mimetype);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.setComponent(null);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            intent.setSelector(null);
        }
        ResolveInfo info = context.getPackageManager().resolveActivity(intent,
            PackageManager.MATCH_DEFAULT_ONLY);
        if (info != null) {
            // If we resolved to ourselves, we don't want to attempt to
            // load the url only to try and download it again.
            if (BuildConfig.APPLICATION_ID.equals(info.activityInfo.packageName)
                || MainActivity.class.getName().equals(info.activityInfo.name)) {
                // someone (other than us) knows how to handle this mime
                // type with this scheme, don't download.
                try {
                    context.startActivity(intent);
                    return;
                } catch (ActivityNotFoundException ex) {
                    // Best behavior is to fall back to a download in this
                    // case
                }
            }
        }
    }
    onDownloadStartNoStream(context, manager, url, userAgent, contentDisposition, mimetype, contentSize);
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:55,代碼來源:DownloadHandler.java


注:本文中的android.content.Intent.setSelector方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。