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

The following examples show how to use android.content.Intent#toUri() . 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
Source File: SSIActivityRunner.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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
Source File: AppPickerPreference.java    From GravityBox with 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 3
Source File: DefaultActivityRunner.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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 4
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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
Source File: DispatchService.java    From sana.mobile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 7
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 13
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 15
Source File: SettingsActivity.java    From ToGoZip with GNU General Public License v3.0 5 votes vote down vote up
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 16
Source File: Tool.java    From openlauncher with 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 17
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 18
Source File: ApplicationPackageManager.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@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 19
Source File: DelegateApplicationPackageManager.java    From AndroidDownload with Apache License 2.0 5 votes vote down vote up
@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
Source File: AppUtils.java    From RelaxFinger with GNU General Public License v2.0 3 votes vote down vote up
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);
    }