java类android.annotation.NonNull的实例源码

a.java 文件源码 项目:ProgressManager 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Convenience for calling
 * {@link android.view.Window#getLayoutInflater}.
 */
@NonNull
public LayoutInflater getLayoutInflater() {
    return getWindow().getLayoutInflater();
}
a.java 文件源码 项目:ProgressManager 阅读 26 收藏 0 点赞 0 评论 0
/**
 * Convenience for calling
 * {@link android.view.Window#getLayoutInflater}.
 */
@NonNull
public LayoutInflater getLayoutInflater() {
    return getWindow().getLayoutInflater();
}
a.java 文件源码 项目:ProgressManager 阅读 31 收藏 0 点赞 0 评论 0
/**
 * Convenience for calling
 * {@link android.view.Window#getLayoutInflater}.
 */
@NonNull
public LayoutInflater getLayoutInflater() {
    return getWindow().getLayoutInflater();
}
a.java 文件源码 项目:ProgressManager 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Convenience for calling
 * {@link android.view.Window#getLayoutInflater}.
 */
@NonNull
public LayoutInflater getLayoutInflater() {
    return getWindow().getLayoutInflater();
}
a.java 文件源码 项目:ProgressManager 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Convenience for calling
 * {@link android.view.Window#getLayoutInflater}.
 */
@NonNull
public LayoutInflater getLayoutInflater() {
    return getWindow().getLayoutInflater();
}
a.java 文件源码 项目:ProgressManager 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Create a new PendingIntent object which you can hand to others
 * for them to use to send result data back to your
 * {@link #onActivityResult} callback.  The created object will be either
 * one-shot (becoming invalid after a result is sent back) or multiple
 * (allowing any number of results to be sent through it).
 *
 * @param requestCode Private request code for the sender that will be
 * associated with the result data when it is returned.  The sender can not
 * modify this value, allowing you to identify incoming results.
 * @param data Default data to supply in the result, which may be modified
 * by the sender.
 * @param flags May be {@link PendingIntent#FLAG_ONE_SHOT PendingIntent.FLAG_ONE_SHOT},
 * {@link PendingIntent#FLAG_NO_CREATE PendingIntent.FLAG_NO_CREATE},
 * {@link PendingIntent#FLAG_CANCEL_CURRENT PendingIntent.FLAG_CANCEL_CURRENT},
 * {@link PendingIntent#FLAG_UPDATE_CURRENT PendingIntent.FLAG_UPDATE_CURRENT},
 * or any of the flags as supported by
 * {@link Intent#fillIn Intent.fillIn()} to control which unspecified parts
 * of the intent that can be supplied when the actual send happens.
 *
 * @return Returns an existing or new PendingIntent matching the given
 * parameters.  May return null only if
 * {@link PendingIntent#FLAG_NO_CREATE PendingIntent.FLAG_NO_CREATE} has been
 * supplied.
 *
 * @see PendingIntent
 */
public PendingIntent createPendingResult(int requestCode, @NonNull Intent data,
                                         @PendingIntent.Flags int flags) {
    String packageName = getPackageName();
    try {
        data.prepareToLeaveProcess(this);
        IIntentSender target =
                ActivityManagerNative.getDefault().getIntentSender(
                        ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
                        mParent == null ? mToken : mParent.mToken,
                        mEmbeddedID, requestCode, new Intent[] { data }, null, flags, null,
                        UserHandle.myUserId());
        return target != null ? new PendingIntent(target) : null;
    } catch (RemoteException e) {
        // Empty
    }
    return null;
}
a.java 文件源码 项目:ProgressManager 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Requests permissions to be granted to this application. These permissions
 * must be requested in your manifest, they should not be granted to your app,
 * and they should have protection level {@link android.content.pm.PermissionInfo
 * #PROTECTION_DANGEROUS dangerous}, regardless whether they are declared by
 * the platform or a third-party app.
 * <p>
 * Normal permissions {@link android.content.pm.PermissionInfo#PROTECTION_NORMAL}
 * are granted at install time if requested in the manifest. Signature permissions
 * {@link android.content.pm.PermissionInfo#PROTECTION_SIGNATURE} are granted at
 * install time if requested in the manifest and the signature of your app matches
 * the signature of the app declaring the permissions.
 * </p>
 * <p>
 * If your app does not have the requested permissions the user will be presented
 * with UI for accepting them. After the user has accepted or rejected the
 * requested permissions you will receive a callback on {@link
 * #onRequestPermissionsResult(int, String[], int[])} reporting whether the
 * permissions were granted or not.
 * </p>
 * <p>
 * Note that requesting a permission does not guarantee it will be granted and
 * your app should be able to run without having this permission.
 * </p>
 * <p>
 * This method may start an activity allowing the user to choose which permissions
 * to grant and which to reject. Hence, you should be prepared that your activity
 * may be paused and resumed. Further, granting some permissions may require
 * a restart of you application. In such a case, the system will recreate the
 * activity stack before delivering the result to {@link
 * #onRequestPermissionsResult(int, String[], int[])}.
 * </p>
 * <p>
 * When checking whether you have a permission you should use {@link
 * #checkSelfPermission(String)}.
 * </p>
 * <p>
 * Calling this API for permissions already granted to your app would show UI
 * to the user to decide whether the app can still hold these permissions. This
 * can be useful if the way your app uses data guarded by the permissions
 * changes significantly.
 * </p>
 * <p>
 * You cannot request a permission if your activity sets {@link
 * android.R.styleable#AndroidManifestActivity_noHistory noHistory} to
 * <code>true</code> because in this case the activity would not receive
 * result callbacks including {@link #onRequestPermissionsResult(int, String[], int[])}.
 * </p>
 * <p>
 * The <a href="http://developer.android.com/samples/RuntimePermissions/index.html">
 * RuntimePermissions</a> sample app demonstrates how to use this method to
 * request permissions at run time.
 * </p>
 *
 * @param permissions The requested permissions. Must me non-null and not empty.
 * @param requestCode Application specific request code to match with a result
 *    reported to {@link #onRequestPermissionsResult(int, String[], int[])}.
 *    Should be >= 0.
 *
 * @see #onRequestPermissionsResult(int, String[], int[])
 * @see #checkSelfPermission(String)
 * @see #shouldShowRequestPermissionRationale(String)
 */
public final void requestPermissions(@NonNull String[] permissions, int requestCode) {
    if (mHasCurrentPermissionsRequest) {
        Log.w(TAG, "Can reqeust only one set of permissions at a time");
        // Dispatch the callback with empty arrays which means a cancellation.
        onRequestPermissionsResult(requestCode, new String[0], new int[0]);
        return;
    }
    Intent intent = getPackageManager().buildRequestPermissionsIntent(permissions);
    startActivityForResult(REQUEST_PERMISSIONS_WHO_PREFIX, intent, requestCode, null);
    mHasCurrentPermissionsRequest = true;
}
a.java 文件源码 项目:ProgressManager 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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
    }
}
a.java 文件源码 项目:ProgressManager 阅读 27 收藏 0 点赞 0 评论 0
/**
 * 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
    }
}
a.java 文件源码 项目:ProgressManager 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Requests permissions to be granted to this application. These permissions
 * must be requested in your manifest, they should not be granted to your app,
 * and they should have protection level {@link android.content.pm.PermissionInfo
 * #PROTECTION_DANGEROUS dangerous}, regardless whether they are declared by
 * the platform or a third-party app.
 * <p>
 * Normal permissions {@link android.content.pm.PermissionInfo#PROTECTION_NORMAL}
 * are granted at install time if requested in the manifest. Signature permissions
 * {@link android.content.pm.PermissionInfo#PROTECTION_SIGNATURE} are granted at
 * install time if requested in the manifest and the signature of your app matches
 * the signature of the app declaring the permissions.
 * </p>
 * <p>
 * If your app does not have the requested permissions the user will be presented
 * with UI for accepting them. After the user has accepted or rejected the
 * requested permissions you will receive a callback on {@link
 * #onRequestPermissionsResult(int, String[], int[])} reporting whether the
 * permissions were granted or not.
 * </p>
 * <p>
 * Note that requesting a permission does not guarantee it will be granted and
 * your app should be able to run without having this permission.
 * </p>
 * <p>
 * This method may start an activity allowing the user to choose which permissions
 * to grant and which to reject. Hence, you should be prepared that your activity
 * may be paused and resumed. Further, granting some permissions may require
 * a restart of you application. In such a case, the system will recreate the
 * activity stack before delivering the result to {@link
 * #onRequestPermissionsResult(int, String[], int[])}.
 * </p>
 * <p>
 * When checking whether you have a permission you should use {@link
 * #checkSelfPermission(String)}.
 * </p>
 * <p>
 * Calling this API for permissions already granted to your app would show UI
 * to the user to decide whether the app can still hold these permissions. This
 * can be useful if the way your app uses data guarded by the permissions
 * changes significantly.
 * </p>
 * <p>
 * You cannot request a permission if your activity sets {@link
 * android.R.styleable#AndroidManifestActivity_noHistory noHistory} to
 * <code>true</code> because in this case the activity would not receive
 * result callbacks including {@link #onRequestPermissionsResult(int, String[], int[])}.
 * </p>
 * <p>
 * The <a href="http://developer.android.com/samples/RuntimePermissions/index.html">
 * RuntimePermissions</a> sample app demonstrates how to use this method to
 * request permissions at run time.
 * </p>
 *
 * @param permissions The requested permissions. Must me non-null and not empty.
 * @param requestCode Application specific request code to match with a result
 *    reported to {@link #onRequestPermissionsResult(int, String[], int[])}.
 *    Should be >= 0.
 *
 * @see #onRequestPermissionsResult(int, String[], int[])
 * @see #checkSelfPermission(String)
 * @see #shouldShowRequestPermissionRationale(String)
 */
public final void requestPermissions(@NonNull String[] permissions, int requestCode) {
    if (mHasCurrentPermissionsRequest) {
        Log.w(TAG, "Can reqeust only one set of permissions at a time");
        // Dispatch the callback with empty arrays which means a cancellation.
        onRequestPermissionsResult(requestCode, new String[0], new int[0]);
        return;
    }
    Intent intent = getPackageManager().buildRequestPermissionsIntent(permissions);
    startActivityForResult(REQUEST_PERMISSIONS_WHO_PREFIX, intent, requestCode, null);
    mHasCurrentPermissionsRequest = true;
}


问题


面经


文章

微信
公众号

扫码关注公众号