本文整理汇总了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();
}
}
示例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;
}
}
示例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;
}
示例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;
}