當前位置: 首頁>>代碼示例>>Java>>正文


Java ComponentName.flattenToString方法代碼示例

本文整理匯總了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;
}
 
開發者ID:TaRGroup,項目名稱:IFWManager,代碼行數:9,代碼來源:StringFilter.java

示例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&lt;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
    }
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:68,代碼來源:a.java


注:本文中的android.content.ComponentName.flattenToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。