本文整理匯總了Java中android.support.v4.app.Fragment.shouldShowRequestPermissionRationale方法的典型用法代碼示例。如果您正苦於以下問題:Java Fragment.shouldShowRequestPermissionRationale方法的具體用法?Java Fragment.shouldShowRequestPermissionRationale怎麽用?Java Fragment.shouldShowRequestPermissionRationale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.app.Fragment
的用法示例。
在下文中一共展示了Fragment.shouldShowRequestPermissionRationale方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: reqFragmentPermission
import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static void reqFragmentPermission(Fragment fragment, final Activity mContext, final String Text, int PermissionCode, String Permission) {
if (!fragment.shouldShowRequestPermissionRationale(Permission)) {
fragment.requestPermissions(new String[]{Permission}, PermissionCode);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
builder.setCancelable(false);
builder.setTitle("Permission");
builder.setMessage("You needs to Grant Access " + Text + " From Settings >> AppInfo >> Permissions For Using Application");
builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
//
dialog.dismiss();
String packageName = Utils.getAppPackageName(mContext);
try {
//Open the specific App Info page:
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setData(Uri.parse("package:" + packageName));
mContext.startActivity(intent);
} catch (ActivityNotFoundException e) {
//e.printStackTrace();
Toast.makeText(mContext, "You need to Grant Access " + Text + " From Settings >> AppInfo >> Permissions For Using Application", Toast.LENGTH_SHORT).show();
}
}
});
// Create the AlertDialog object and return it
builder.create().show();
}
}