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


Java PermissionsResultAction类代码示例

本文整理汇总了Java中com.anthonycr.grant.PermissionsResultAction的典型用法代码示例。如果您正苦于以下问题:Java PermissionsResultAction类的具体用法?Java PermissionsResultAction怎么用?Java PermissionsResultAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onCreate

import com.anthonycr.grant.PermissionsResultAction; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Requesting all the permissions in the manifest
    PermissionsManager.getInstance().requestAllManifestPermissionsIfNecessary(this, new PermissionsResultAction() {
        @Override
        public void onGranted() {
            Toast.makeText(MainActivity.this, R.string.message_granted, Toast.LENGTH_SHORT).show();
            writeToStorage("Hello, World!");
            readFromStorage();
        }

        @Override
        public void onDenied(String permission) {
            String message = String.format(Locale.getDefault(), getString(R.string.message_denied), permission);
            Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
        }
    });

    boolean hasPermission = PermissionsManager.getInstance().hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
    Log.d(TAG, "Has " + Manifest.permission.READ_EXTERNAL_STORAGE + " permission: " + hasPermission);

    Button writeStorage = (Button) findViewById(R.id.button_write_storage);
    Button readStorage = (Button) findViewById(R.id.button_read_storage);
    Button readContacts = (Button) findViewById(R.id.button_read_contacts);
    Button getLocation = (Button) findViewById(R.id.button_get_location);

    this.textView = (TextView) findViewById(R.id.text);

    writeStorage.setOnClickListener(this);
    readStorage.setOnClickListener(this);
    readContacts.setOnClickListener(this);
    getLocation.setOnClickListener(this);
}
 
开发者ID:wudongze,项目名称:Grant-master,代码行数:36,代码来源:MainActivity.java

示例2: checkPermissions

import com.anthonycr.grant.PermissionsResultAction; //导入依赖的package包/类
private void checkPermissions() {
    PermissionsManager.getInstance().requestAllManifestPermissionsIfNecessary(this, new PermissionsResultAction() {
        @Override
        public void onGranted() {
        }

        @Override
        public void onDenied(String permission) {
            String message = String.format(Locale.getDefault(), getString(R.string.message_denied), permission);
            Toast.makeText(MyBrowserActivity.this, message, Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:wade-fs,项目名称:MediaManager,代码行数:14,代码来源:MyBrowserActivity.java

示例3: onCreate

import com.anthonycr.grant.PermissionsResultAction; //导入依赖的package包/类
@SuppressLint("InlinedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Requesting all the permissions in the manifest
    PermissionsManager.getInstance().requestAllManifestPermissionsIfNecessary(this, new PermissionsResultAction() {
        @Override
        public void onGranted() {
            Toast.makeText(MainActivity.this, R.string.message_granted, Toast.LENGTH_SHORT).show();
            writeToStorage("Hello, World!");
            readFromStorage();
        }

        @Override
        public void onDenied(String permission) {
            String message = String.format(Locale.getDefault(), getString(R.string.message_denied), permission);
            Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
        }
    });

    boolean hasPermission = PermissionsManager.getInstance().hasPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
    Log.d(TAG, "Has " + Manifest.permission.READ_EXTERNAL_STORAGE + " permission: " + hasPermission);

    Button writeStorage = (Button) findViewById(R.id.button_write_storage);
    Button readStorage = (Button) findViewById(R.id.button_read_storage);
    Button readContacts = (Button) findViewById(R.id.button_read_contacts);
    Button getLocation = (Button) findViewById(R.id.button_get_location);

    this.textView = (TextView) findViewById(R.id.text);

    writeStorage.setOnClickListener(this);
    readStorage.setOnClickListener(this);
    readContacts.setOnClickListener(this);
    getLocation.setOnClickListener(this);
}
 
开发者ID:anthonycr,项目名称:Grant,代码行数:37,代码来源:MainActivity.java

示例4: checkPermissions

import com.anthonycr.grant.PermissionsResultAction; //导入依赖的package包/类
private void checkPermissions() {
    PermissionsManager.getInstance().requestAllManifestPermissionsIfNecessary(this, new PermissionsResultAction() {
        @Override
        public void onGranted() {
        }

        @Override
        public void onDenied(String permission) {
            String message = String.format(Locale.getDefault(), getString(R.string.message_denied), permission);
            Toast.makeText(AbstractBrowserActivity.this, message, Toast.LENGTH_SHORT).show();
        }
    });
}
 
开发者ID:DF1E,项目名称:SimpleExplorer,代码行数:14,代码来源:AbstractBrowserActivity.java


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