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