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


Java Intent.toUri方法代码示例

本文整理汇总了Java中android.content.Intent.toUri方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.toUri方法的具体用法?Java Intent.toUri怎么用?Java Intent.toUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Intent的用法示例。


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

示例1: onActivityResult

import android.content.Intent; //导入方法依赖的package包/类
@Override
@TargetApi(21)
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        String uri = data.toUri(0);
        MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(Activity.MEDIA_PROJECTION_SERVICE);
        MediaProjection mediaProjection = projectionManager.getMediaProjection(resultCode, data);

        ScreenCaptureService.setMediaProjection(mediaProjection);

        startService(new Intent(ScreenCaptureService.ACTION_START, null, this, ScreenCaptureService.class));
        fab.setSelected(true);
    }

    if (requestCode == REQUEST_CODE_MAKE_SMING && resultCode == RESULT_OK) {
        loadSmings();
        checkEmpty();
    }
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:20,代码来源:MainActivity.java

示例2: convertOldValueFormat

import android.content.Intent; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:18,代码来源:AppPickerPreference.java

示例3: shortcutExists

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Returns true if the shortcuts already exists on the workspace. This must be called after
 * the workspace has been loaded. We identify a shortcut by its intent.
 */
private boolean shortcutExists(BgDataModel dataModel, Intent intent, UserHandle user) {
    final String intentWithPkg, intentWithoutPkg;
    if (intent == null) {
        // Skip items with null intents
        return true;
    }
    if (intent.getComponent() != null) {
        // If component is not null, an intent with null package will produce
        // the same result and should also be a match.
        String packageName = intent.getComponent().getPackageName();
        if (intent.getPackage() != null) {
            intentWithPkg = intent.toUri(0);
            intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
        } else {
            intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
            intentWithoutPkg = intent.toUri(0);
        }
    } else {
        intentWithPkg = intent.toUri(0);
        intentWithoutPkg = intent.toUri(0);
    }

    synchronized (dataModel) {
        for (ItemInfo item : dataModel.itemsIdMap) {
            if (item instanceof ShortcutInfo) {
                ShortcutInfo info = (ShortcutInfo) item;
                if (item.getIntent() != null && info.user.equals(user)) {
                    Intent copyIntent = new Intent(item.getIntent());
                    copyIntent.setSourceBounds(intent.getSourceBounds());
                    String s = copyIntent.toUri(0);
                    if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:44,代码来源:AddWorkspaceItemsTask.java

示例4: shortcutExists

import android.content.Intent; //导入方法依赖的package包/类
/**
 * Returns true if the shortcuts already exists on the workspace. This must be called after
 * the workspace has been loaded. We identify a shortcut by its intent.
 */
@Thunk boolean shortcutExists(Context context, Intent intent, UserHandleCompat user) {
    assertWorkspaceLoaded();
    final String intentWithPkg, intentWithoutPkg;
    if (intent.getComponent() != null) {
        // If component is not null, an intent with null package will produce
        // the same result and should also be a match.
        String packageName = intent.getComponent().getPackageName();
        if (intent.getPackage() != null) {
            intentWithPkg = intent.toUri(0);
            intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
        } else {
            intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
            intentWithoutPkg = intent.toUri(0);
        }
    } else {
        intentWithPkg = intent.toUri(0);
        intentWithoutPkg = intent.toUri(0);
    }

    synchronized (sBgLock) {
        for (ItemInfo item : sBgItemsIdMap) {
            if (item instanceof ShortcutInfo) {
                ShortcutInfo info = (ShortcutInfo) item;
                Intent targetIntent = info.promisedIntent == null
                        ? info.intent : info.promisedIntent;
                if (targetIntent != null && info.user.equals(user)) {
                    Intent copyIntent = new Intent(targetIntent);
                    copyIntent.setSourceBounds(intent.getSourceBounds());
                    String s = copyIntent.toUri(0);
                    if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:43,代码来源:LauncherModel.java


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