Java Code Examples for android.content.Intent#toUri()

The following examples show how to use android.content.Intent#toUri() . These examples are extracted from open source projects. 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
@Override
public Intent next(Intent response) {
    Intent request = response.getParcelableExtra(Intents.EXTRA_REQUEST);
    // Log input and output if we are debugging
    String reqLog = (request != null) ? request.toUri(Intent.URI_INTENT_SCHEME) : "null";
    String respLog = (response != null) ? response.toUri(Intent.URI_INTENT_SCHEME) : "null";
    Logf.D(TAG, "next(Intent,Intent)", String.format("request=%s;response=%s", reqLog, respLog));

    // check for a null intent equivalent to CANCEL
    if (response.getAction().equals(Intents.ACTION_CANCEL)) {
        response = handleCancel(request, response);
    } else {
        response = handleOk(request, response);
    }
    return response;
}
 
Example 2
@Override
public Intent next(Intent response) {
    // get the previous state
    Intent request = (stack.size() >= 1) ? stack.pop() : null;

    // Log request and response
    String reqLog = (request != null) ? request.toUri(Intent.URI_INTENT_SCHEME) : "null";
    String respLog = (response != null) ? response.toUri(Intent.URI_INTENT_SCHEME) : "null";
    Logf.I(TAG, "next(Intent)", String.format("request=%s;response=%s", reqLog, respLog));

    // check for a null intent equivalent to CANCEL
    if (response == null) {
        stack.push(handleCancel(request));
    } else {
        stack.push(handleOk(request, response));
    }
    return Intents.copyOf(stack.peek());
}
 
Example 3
Source Project: GravityBox   File: AppPickerPreference.java    License: Apache License 2.0 6 votes vote down vote up
private String convertOldValueFormat(String oldValue) {
    try {
        String[] splitValue = oldValue.split(SEPARATOR);
        ComponentName cn = new ComponentName(splitValue[0], splitValue[1]);
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setComponent(cn);
        intent.putExtra("mode", MODE_APP);
        String newValue = intent.toUri(0);
        setValue(newValue);
        Log.d(TAG, "Converted old AppPickerPreference value: " + newValue);
        return newValue;
    } catch (Exception e) {
        Log.e(TAG, "Error converting old AppPickerPreference value: " + e.getMessage());
        return null;
    }
}
 
Example 4
@Override public Drawable getActivityIcon(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityIcon(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadIcon(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 5
@Override
public Drawable getActivityLogo(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityLogo(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadLogo(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 6
@Override public Drawable getActivityIcon(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityIcon(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadIcon(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 7
@Override
public Drawable getActivityLogo(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityLogo(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
            intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadLogo(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 8
@Override
public Drawable getActivityLogo(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityLogo(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadLogo(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 9
@Override public Drawable getActivityIcon(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityIcon(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadIcon(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 10
Source Project: openlauncher   File: Tool.java    License: Apache License 2.0 5 votes vote down vote up
public static String getIntentAsString(Intent intent) {
    if (intent == null) {
        return "";
    } else {
        return intent.toUri(0);
    }
}
 
Example 11
private boolean onCmdSend(CharSequence title) {
    ZipStorage storage = SettingsImpl.getCurrentZipStorage(this);
    Intent intent = new Intent(Intent.ACTION_SEND);
    Uri contentUri = Uri.parse(storage.getFullZipUriOrNull());
    String mime = "application/zip";

    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
            Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);


    // EXTRA_CC, EXTRA_BCC
    // intent.putExtra(Intent.EXTRA_EMAIL, new String[]{toAddress});

    intent.putExtra(Intent.EXTRA_SUBJECT, SettingsImpl.getZipFile());

    // intent.putExtra(Intent.EXTRA_TEXT, body);

    intent.putExtra(Intent.EXTRA_STREAM, contentUri);

    intent.setType(mime);

    final String debugMessage = "SettingsActivity.onCmdSend(" +
            title +
            ", startActivity='" + intent.toUri(0)
            + "')";
    try {
        final Intent chooser = Intent.createChooser(intent, title);
        chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
        this.startActivity(chooser);
        if (Global.debugEnabled) {
            Log.d(Global.LOG_CONTEXT, debugMessage);
        }
    }
    catch(Exception ex) {
        Log.w(Global.LOG_CONTEXT, debugMessage, ex);
    }

    return true;
}
 
Example 12
@Override
public Drawable getActivityLogo(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityLogo(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadLogo(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 13
@Override public Drawable getActivityIcon(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityIcon(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadIcon(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 14
@Override
public Drawable getActivityBanner(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityBanner(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
            intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadBanner(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 15
@Override
public Drawable getActivityLogo(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityLogo(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadLogo(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 16
@Override public Drawable getActivityIcon(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityIcon(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadIcon(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 17
@Override
public Drawable getActivityBanner(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityBanner(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
            intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadBanner(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 18
public Message obtainRequest(Handler handler, int who, Intent intent) {
    int what = Uris.getDescriptor(intent.getData());
    Message msg = handler.obtainMessage(what,
            intent.toUri(Intent.URI_INTENT_SCHEME));
    msg.arg1 = intent.filterHashCode();
    msg.arg2 = REQUEST;
    msg.obj = intent.toUri(Intent.URI_INTENT_SCHEME);

    return msg;
}
 
Example 19
@Override
public Drawable getActivityLogo(Intent intent)
        throws NameNotFoundException {
    if (intent.getComponent() != null) {
        return getActivityLogo(intent.getComponent());
    }

    ResolveInfo info = resolveActivity(
        intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null) {
        return info.activityInfo.loadLogo(this);
    }

    throw new NameNotFoundException(intent.toUri(0));
}
 
Example 20
public static String getIntentUri(ResolveInfo resolveInfo){


        Intent intent = new Intent();

        String pkgName = resolveInfo.activityInfo.packageName;
        String clsName = resolveInfo.activityInfo.name;

        intent.setComponent(new ComponentName(pkgName,clsName));

        return intent.toUri(Intent.FLAG_ACTIVITY_NEW_TASK);
    }