List of usage examples for android.content.pm PackageManager PERMISSION_GRANTED
int PERMISSION_GRANTED
To view the source code for android.content.pm PackageManager PERMISSION_GRANTED.
Click Source Link
From source file:jp.mixi.android.sdk.MixiContainerImpl.java
private boolean validatePermission(Context context) { if (context//w w w .jav a 2 s. c o m .checkCallingOrSelfPermission(Manifest.permission.INTERNET) != PackageManager.PERMISSION_GRANTED) { Log.w(TAG, "No permission Manifest.permission.INTERNET"); Builder alertBuilder = new Builder(context); alertBuilder.setMessage(context.getString(R.string.no_permission_error)); alertBuilder.create().show(); return false; } return true; }
From source file:com.albedinsky.android.support.universi.UniversiActivity.java
/** *//*from w w w .j ava 2 s .c om*/ @Override public int checkSelfPermission(@NonNull String permission) { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? super.checkSelfPermission(permission) : PackageManager.PERMISSION_GRANTED; }
From source file:com.adwhirl.AdWhirlManager.java
public Location getLocation() { if (contextReference == null) { return null; }//from w ww.j a va 2 s. c o m Context context = contextReference.get(); if (context == null) { return null; } Location location = null; if (context.checkCallingOrSelfPermission( android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); } else if (context.checkCallingOrSelfPermission( android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } return location; }
From source file:bmcx.aiton.com.passenger.view.activity.SmsLoginActivity.java
@Override public void onClick(View v) { Intent intent = new Intent(); switch (v.getId()) { case R.id.textView_frogetPassword: intent.setClass(SmsLoginActivity.this, UpdatePasswordActivity.class); startActivity(intent);/*from w ww . j a v a 2 s. c o m*/ break; case R.id.textView_register: intent.setClass(SmsLoginActivity.this, RegisterActivity.class); startActivity(intent); break; case R.id.textView_quickLogin: isQuickLogin = true; mTextView_quickLogin.setTextColor(basicColor); mTextView_accountLogin.setTextColor(mSystem_gray); Animation animation = new TranslateAnimation(offset, 0, 0, 0); animation.setFillAfter(true);// True:??? animation.setDuration(300); mImageView_tiao01.startAnimation(animation); mLogin.setVisibility(View.GONE); mLinear_quickLogin.setVisibility(View.VISIBLE); mLinear_accountLogin.setVisibility(View.INVISIBLE); break; case R.id.textView_accountLogin: isQuickLogin = false; mTextView_accountLogin.setTextColor(basicColor); mTextView_quickLogin.setTextColor(mSystem_gray); Animation animation02 = new TranslateAnimation(0, offset, 0, 0); animation02.setFillAfter(true);// True:??? animation02.setDuration(300); mImageView_tiao01.startAnimation(animation02); mLogin.setVisibility(View.VISIBLE); mLinear_quickLogin.setVisibility(View.INVISIBLE); mLinear_accountLogin.setVisibility(View.VISIBLE); break; case R.id.login: if (isQuickLogin) { if (mSuijiMath.equals(mSms.getText().toString().trim())) { //? final String DeviceId = Installation.id(SmsLoginActivity.this); //??????????----start----// Map<String, String> params = new HashMap<>(); params.put("phone", mPhoneNum); params.put("login_id", DeviceId); ApiClient.smsLogingSuccess(SmsLoginActivity.this, params, new VolleyListener() { public void onErrorResponse(VolleyError volleyError) { } public void onResponse(String s) { Log.e("SmsLoginActivity", "onResponse: --??????->>" + s); mUser = GsonUtils.parseJSON(s, User.class); if (mUser.isSuccess()) { Log.e("SmsLoginActivity", "onResponse: --????->>" + mLoginState.isLogin()); toast("??"); //???????? mLoginState.login(SmsLoginActivity.this); Log.e("SmsLoginActivity", "onResponse: --?????->>" + mLoginState.isLogin()); //???id?? UserLoginInfo userLoginInfo = new UserLoginInfo(mPhoneNum, "" + mUser.getContains().getId(), DeviceId, mUser.getContains().getImage(), mUser.getContains().getIdCardImage(), mUser.getContains().getIdCardImage_back(), mUser.getContains().getDrivingLicenseImage(), mUser.getContains().getDrivingLicenseImage_back()); mLoginState.setLoginInfo(userLoginInfo); Log.e("SmsLoginActivity", "onResponse: --?->>" + mLoginState.getLoginInfo().toString()); //? MobclickAgent.onProfileSignIn(mPhoneNum); finish(); } else { toast(mUser.getMessage()); } } }); //??????????----end----// } else { toast("?"); } } else { mPhoneNum = mEditText_phoneNum.getText().toString().trim(); String password = mEditText_password.getText().toString().trim(); //? final String DeviceId = Installation.id(SmsLoginActivity.this); Map<String, String> map = new HashMap<>(); map.put("phone", mPhoneNum); map.put("login_id", DeviceId); map.put("password", password); ApiClient.passWordLoginSuccess(SmsLoginActivity.this, map, new VolleyListener() { @Override public void onErrorResponse(VolleyError volleyError) { } @Override public void onResponse(String s) { mUser = GsonUtils.parseJSON(s, User.class); if (mUser.isSuccess()) { Log.e("SmsLoginActivity", "onResponse: --????->>" + mLoginState.isLogin()); //???????? mLoginState.login(SmsLoginActivity.this); Log.e("SmsLoginActivity", "onResponse: --?????->>" + mLoginState.isLogin()); //???id?? UserLoginInfo userLoginInfo = new UserLoginInfo(mPhoneNum, "" + mUser.getContains().getId(), DeviceId, mUser.getContains().getImage(), mUser.getContains().getIdCardImage(), mUser.getContains().getIdCardImage_back(), mUser.getContains().getDrivingLicenseImage(), mUser.getContains().getDrivingLicenseImage_back()); mLoginState.setLoginInfo(userLoginInfo); toast("?"); //? MobclickAgent.onProfileSignIn(mPhoneNum); finish(); // Intent intent = new Intent(); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // intent.setClass(SmsLoginActivity.this, MainActivity.class); // startActivity(intent); } else { toast("???"); } } }); } break; case R.id.iv_org_detailback: finish(); AnimFromRightToLeft(); break; case R.id.phone_num_cancle: mPhone_num.setText(""); break; case R.id.sms_cancle: mSms.setText(""); break; case R.id.sendSms: if (ContextCompat.checkSelfPermission(SmsLoginActivity.this, Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED) { //WRITE_EXTERNAL_STORAGE?? ActivityCompat.requestPermissions(SmsLoginActivity.this, new String[] { Manifest.permission.READ_SMS }, Constant.PermissionRequestAndResultCode.PERMISSION_READ_SMS); } else { sendSMS(); } break; } }
From source file:com.amazonaws.mobile.auth.google.GoogleSignInProvider.java
private boolean getPermissionsIfNecessary(final Activity activity) { if (ContextCompat.checkSelfPermission(activity.getApplicationContext(), Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) { this.activityWeakReference = new WeakReference<Activity>(activity); ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.GET_ACCOUNTS }, GET_ACCOUNTS_PERMISSION_REQUEST_CODE); return true; }//from w ww .j a v a 2s.c o m return false; }
From source file:com.alibaba.weex.IndexActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_refresh: if (!TextUtils.equals(sCurrentIp, DEFAULT_IP)) { createWeexInstance();/*w ww . j av a 2 s . c om*/ renderPageByURL(getIndexUrl()); mProgressBar.setVisibility(View.VISIBLE); } break; case R.id.action_scan: if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) { Toast.makeText(this, "please give me the permission", Toast.LENGTH_SHORT).show(); } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA }, CAMERA_PERMISSION_REQUEST_CODE); } } else { startActivity(new Intent(this, CaptureActivity.class)); } break; default: break; } return super.onOptionsItemSelected(item); }
From source file:com.alibaba.weex.extend.module.location.DefaultLocation.java
private WXLocationListener findLocation(String watchId, String sucCallback, String errorCallback, boolean enableHighAccuracy, boolean enableAddress) { // WXLogUtils.d(TAG, "into--[findLocation] mWatchId:" + watchId + "\nsuccessCallback:" + sucCallback + "\nerrorCallback:" + errorCallback + "\nenableHighAccuracy:" + enableHighAccuracy + "\nmEnableAddress:" + enableAddress); if (mLocationManager == null) { mLocationManager = (LocationManager) mWXSDKInstance.getContext() .getSystemService(Context.LOCATION_SERVICE); }/*from ww w . j ava 2 s .c o m*/ Criteria criteria = new Criteria(); if (enableHighAccuracy) { criteria.setAccuracy(Criteria.ACCURACY_COARSE); } //String provider = locationManager.getBestProvider(criteria, false); if (ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { WXLocationListener WXLocationListener = new WXLocationListener(mLocationManager, mWXSDKInstance, watchId, sucCallback, errorCallback, enableAddress); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DISTANCE, WXLocationListener); mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, MIN_TIME, MIN_DISTANCE, WXLocationListener); return WXLocationListener; } else { Map<String, Object> options = new HashMap<>(); options.put(ERROR_CODE, ErrorCode.NO_PERMISSION_ERROR); options.put(ERROR_MSG, ErrorMsg.NO_PERMISSION_ERROR); WXSDKManager.getInstance().callback(mWXSDKInstance.getInstanceId(), errorCallback, options); } return null; }
From source file:de.tap.easy_xkcd.fragments.comics.ComicBrowserFragment.java
/************************* * Favorite Modification/*from w w w. ja v a 2 s . c o m*/ ************************/ protected boolean ModifyFavorites(MenuItem item) { if (!prefHelper.isOnline(getActivity())) { Toast.makeText(getActivity(), R.string.no_connection, Toast.LENGTH_SHORT).show(); return true; } if (databaseManager.checkFavorite(lastComicNumber)) { new DeleteComicImageTask().execute(true); item.setIcon(R.drawable.ic_favorite_outline); } else { if (!(ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) { ActivityCompat.requestPermissions(getActivity(), new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 2); return true; } new SaveComicImageTask().execute(true); item.setIcon(R.drawable.ic_action_favorite); } return true; }
From source file:com.example.devesh.Coride.DriverRegistration.java
@TargetApi(Build.VERSION_CODES.M) public void sendData(View view) throws MalformedURLException { Log.e("TEST LOG", "Entered the loop"); Toast.makeText(this, "coride", Toast.LENGTH_SHORT).show(); Master master = new Master(); String url_string = master.url + "driverdata"; EditText n_edittext;//from ww w . ja va 2s . c o m EditText mob_edittext; EditText confrm_edittext; EditText age_edittext; EditText lnumber; EditText pnumber; EditText vnumber; EditText mnumber; EditText capacity; String name; String mobile; String conpassword; String password; String address; String email; String slnumber; String spnumber; String svnumber; String smnumber; String scapacity; int count = 0; n_edittext = (EditText) findViewById(R.id.name); mob_edittext = (EditText) findViewById(R.id.mobileno); confrm_edittext = (EditText) findViewById(R.id.confirmpassword); mPasswordView = (EditText) findViewById(R.id.password); mEmailView = (AutoCompleteTextView) findViewById(R.id.email); age_edittext = (EditText) findViewById(R.id.address); lnumber = (EditText) findViewById(R.id.lnumber); pnumber = (EditText) findViewById(R.id.pnumber); vnumber = (EditText) findViewById(R.id.vnumber); mnumber = (EditText) findViewById(R.id.mnumber); capacity = (EditText) findViewById(R.id.capacity); name = n_edittext.getText().toString(); mobile = mob_edittext.getText().toString(); master.mobile1 = mobile; password = mPasswordView.getText().toString(); conpassword = confrm_edittext.getText().toString(); address = age_edittext.getText().toString(); email = mEmailView.getText().toString(); slnumber = lnumber.getText().toString(); spnumber = pnumber.getText().toString(); svnumber = vnumber.getText().toString(); smnumber = mnumber.getText().toString(); ; scapacity = capacity.getText().toString(); regId = registerGCM(); System.out.println(regId); // String reg=regId.toString(); count = validate(name, email, mobile, password, conpassword, address); if (count == 0) { count = email_validation(mEmailView, getBaseContext()); } if (count == 0) { count = password_matcher(password, conpassword); } if (count == 0) { String json = "[{name:\"" + name + "\"},{mobile:\"" + mobile + "\"},{password:\"" + password + "\"},{email:\"" + email + "\"},{address:\"" + address + "\"},{license:\"" + slnumber + "\"},{pan:\"" + spnumber + "\"},{vehicle:\"" + svnumber + "\"},{model:\"" + smnumber + "\"},{capacity:\"" + scapacity + "\"},{regid:\"" + regId + "\"}]"; // snd.addNameValuePair("name", name); //snd.addNameValuePair("mobile", mobile); //snd.addNameValuePair("password", password); // snd.addNameValuePair("email",email); //snd.addNameValuePair("age", age); SendDataTask snd = new SendDataTask(json); //Go to sendData class fromhere URL url = new URL(url_string); snd.execute(url); } System.out.println("i am hear"); LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (locationManager.isProviderEnabled(locationManager.NETWORK_PROVIDER) || locationManager.isProviderEnabled(locationManager.GPS_PROVIDER)) { Log.e("Coride", "Provider enable"); callLocationService(); } else { Log.e("Coride", "provider disabled"); showSettingsAlert("NETWORK_PROVIDER"); } LocationListener locationListener = new LocationListener() { @Override public void onLocationChanged(Location location) { } @Override public void onStatusChanged(String s, int i, Bundle bundle) { } @Override public void onProviderEnabled(String s) { callLocationService(); } @Override public void onProviderDisabled(String s) { showSettingsAlert("NETWORK_PROVIDER"); } }; // dialog.cancel(); if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 123); return; } locationManager.requestLocationUpdates(locationManager.NETWORK_PROVIDER, 0, 0, locationListener); }
From source file:com.adkdevelopment.earthquakesurvival.ui.PagerActivity.java
/** * Method to load permissions for Android 6+ at runtime. * * @param perm The requested permission. * @param requestCode Application specific request code to match with a result * reported to onRequestPermissionsResult(int, String[], int[]) *///from w w w . jav a2 s. c o m private void loadPermissions(String perm, int requestCode) { if (ContextCompat.checkSelfPermission(this, perm) != PackageManager.PERMISSION_GRANTED) { if (!ActivityCompat.shouldShowRequestPermissionRationale(this, perm)) { ActivityCompat.requestPermissions(this, new String[] { perm }, requestCode); } } }