本文整理汇总了Java中android.content.ComponentName.flattenToString方法的典型用法代码示例。如果您正苦于以下问题:Java ComponentName.flattenToString方法的具体用法?Java ComponentName.flattenToString怎么用?Java ComponentName.flattenToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ComponentName
的用法示例。
在下文中一共展示了ComponentName.flattenToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValue
import android.content.ComponentName; //导入方法依赖的package包/类
@Override
public String getValue(ComponentName resolvedComponent, Intent intent,
String resolvedType) {
if (resolvedComponent != null) {
return resolvedComponent.flattenToString();
}
return null;
}
示例2: setVrModeEnabled
import android.content.ComponentName; //导入方法依赖的package包/类
/**
* Enable or disable virtual reality (VR) mode for this Activity.
*
* <p>VR mode is a hint to Android system to switch to a mode optimized for VR applications
* while this Activity has user focus.</p>
*
* <p>It is recommended that applications additionally declare
* {@link android.R.attr#enableVrMode} in their manifest to allow for smooth activity
* transitions when switching between VR activities.</p>
*
* <p>If the requested {@link android.service.vr.VrListenerService} component is not available,
* VR mode will not be started. Developers can handle this case as follows:</p>
*
* <pre>
* String servicePackage = "com.whatever.app";
* String serviceClass = "com.whatever.app.MyVrListenerService";
*
* // Name of the component of the VrListenerService to start.
* ComponentName serviceComponent = new ComponentName(servicePackage, serviceClass);
*
* try {
* setVrModeEnabled(true, myComponentName);
* } catch (PackageManager.NameNotFoundException e) {
* List<ApplicationInfo> installed = getPackageManager().getInstalledApplications(0);
* boolean isInstalled = false;
* for (ApplicationInfo app : installed) {
* if (app.packageName.equals(servicePackage)) {
* isInstalled = true;
* break;
* }
* }
* if (isInstalled) {
* // Package is installed, but not enabled in Settings. Let user enable it.
* startActivity(new Intent(Settings.ACTION_VR_LISTENER_SETTINGS));
* } else {
* // Package is not installed. Send an intent to download this.
* sentIntentToLaunchAppStore(servicePackage);
* }
* }
* </pre>
*
* @param enabled {@code true} to enable this mode.
* @param requestedComponent the name of the component to use as a
* {@link android.service.vr.VrListenerService} while VR mode is enabled.
*
* @throws android.content.pm.PackageManager.NameNotFoundException if the given component
* to run as a {@link android.service.vr.VrListenerService} is not installed, or has
* not been enabled in user settings.
*
* @see android.content.pm.PackageManager#FEATURE_VR_MODE
* @see android.content.pm.PackageManager#FEATURE_VR_MODE_HIGH_PERFORMANCE
* @see android.service.vr.VrListenerService
* @see android.provider.Settings#ACTION_VR_LISTENER_SETTINGS
* @see android.R.attr#enableVrMode
*/
public void setVrModeEnabled(boolean enabled, @NonNull ComponentName requestedComponent)
throws PackageManager.NameNotFoundException {
try {
if (ActivityManagerNative.getDefault().setVrMode(mToken, enabled, requestedComponent)
!= 0) {
throw new PackageManager.NameNotFoundException(
requestedComponent.flattenToString());
}
} catch (RemoteException e) {
// pass
}
}