Java Code Examples for android.content.Intent.setSelector()

The following are Jave code examples for showing how to use setSelector() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: letv   File: ShortcutProxyActivity.java   View Source Code Vote up 6 votes
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();
    }
}
 
Example 2
Project: DroidPlugin   File: ShortcutProxyActivity.java   View Source Code Vote up 6 votes
@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();
    }
}
 
Example 3
Project: LoRaWAN-Smart-Parking   File: CordovaUriHelper.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 4
Project: LoRaWAN-Smart-Parking   File: CordovaUriHelper.java   View Source Code Vote up 6 votes
/**
 * 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;
}
 
Example 5
Project: Xndroid   File: DownloadHandler.java   View Source Code Vote up 5 votes
/**
 * 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);
}