permissions.dispatcher.NeedsPermission Java Examples
The following examples show how to use
permissions.dispatcher.NeedsPermission.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From Mi365Locker with GNU General Public License v3.0 | 6 votes |
@NeedsPermission(Manifest.permission.ACCESS_COARSE_LOCATION) void startScan() { this.scanning = true; if (this.mBTAdapter != null) { RxBleClient client = this.rxBleClient; RxBleClient.State state = client.getState(); if(state == RxBleClient.State.READY) { bluetoothLeScanner.startScan(this.mLeScanCallback); } else { Toast.makeText(this, "Enable bluetooth", Toast.LENGTH_LONG).show(); stopScan(); } } this.updateStatus(); }
Example #2
Source File: DetailControlActivity.java From GSYVideoPlayer with Apache License 2.0 | 6 votes |
/** * 视频截图 * 这里没有做读写本地sd卡的权限处理,记得实际使用要加上 */ @NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) void shotImage(final View v) { //获取截图 detailPlayer.taskShotPic(new GSYVideoShotListener() { @Override public void getBitmap(Bitmap bitmap) { if (bitmap != null) { try { CommonUtil.saveBitmap(bitmap); } catch (FileNotFoundException e) { showToast("save fail "); e.printStackTrace(); return; } showToast("save success "); } else { showToast("get bitmap fail "); } } }); }
Example #3
Source File: ActivityExportCSV.java From fingen with Apache License 2.0 | 6 votes |
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE) void SelectFile() { FileUtils.SelectFileFromStorage(ActivityExportCSV.this, DialogConfigs.FILE_AND_DIR_SELECT, new FileUtils.IOnSelectFile() { @Override public void OnSelectFile(String path) { String dir; String fn; File file = new File(path); if (file.isDirectory()) { dir = path; fn = ""; } else { dir = file.getParent(); fn = file.getName(); } SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ActivityExportCSV.this); preferences.edit().putString("export_dir", dir).putString("export_file", fn).apply(); mEditTextDirectory.setText(dir); mEditTextFileName.setText(fn); } }); }
Example #4
Source File: ActivityEditLocation2.java From fingen with Apache License 2.0 | 6 votes |
@NeedsPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}) void startDetectCoords() { if (location.getID() < 0) { locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (locationManager != null && locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)) if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); } if (locationManager != null && locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)) if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); } } }
Example #5
Source File: ActivityEditTransaction.java From fingen with Apache License 2.0 | 6 votes |
@NeedsPermission({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}) void startDetectCoords() { if (transaction.getLocationID() < 0 & allowUpdateLocation) { locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (locationManager != null && locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)) if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); } if (locationManager != null && locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)) if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); } } }
Example #6
Source File: PhotoActivity.java From CrazyDaily with Apache License 2.0 | 6 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void saveImage() { if (TextUtils.isEmpty(mUrl)) { SnackbarUtil.show(this, "好可怜,保存失败!"); return; } File downloadFile = FileUtil.getDownloadFile(this); if (downloadFile == null) { SnackbarUtil.show(this, "好可怜,保存失败!"); return; } final String fileName = FileUtil.getFileName(this) + mUrl.substring(mUrl.lastIndexOf(".")); final File saveFile = new File(downloadFile, fileName); ImageLoader.downloadFile(this, mUrl, saveFile, isSuccess -> { if (isSuccess) { SnackbarUtil.showLong(this, "保存成功!路径:" + saveFile.getAbsolutePath()); } else { SnackbarUtil.show(this, "好可怜,保存失败!"); } }); }
Example #7
Source File: ActivityImportSms.java From fingen with Apache License 2.0 | 6 votes |
@NeedsPermission(Manifest.permission.READ_SMS) void importSms() { // String sender = editTextSender.getText().toString(); boolean autoCreate = checkboxAutoCreateTransactions.isChecked(); if (mSender.getID() < 0) { Toast.makeText(this, getString(R.string.err_empty_sender), Toast.LENGTH_SHORT).show(); return; } PreferenceManager.getDefaultSharedPreferences(this).edit().putLong("import_sender_id", mSender.getID()).apply(); final SmsImporter smsImporter = new SmsImporter(this, mSender, autoCreate, mStartDate, mEndDate); smsImporter.setmProgressEventsListener(this); handler.sendMessage(handler.obtainMessage(HANDLER_OPERATION_SHOW, 0, 0)); Thread t = new Thread(new Runnable() { @Override public void run() { smsImporter.importSms(); } }); t.start(); }
Example #8
Source File: DetailFilterActivity.java From GSYVideoPlayer with Apache License 2.0 | 6 votes |
/** * 视频截图 */ @NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) void shotImage(final View v) { //获取截图 detailPlayer.taskShotPic(new GSYVideoShotListener() { @Override public void getBitmap(Bitmap bitmap) { if (bitmap != null) { try { CommonUtil.saveBitmap(bitmap); } catch (FileNotFoundException e) { showToast("save fail "); e.printStackTrace(); return; } showToast("save success "); } else { showToast("get bitmap fail "); } } }); }
Example #9
Source File: ActivityBackup.java From fingen with Apache License 2.0 | 6 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void backupDB() { SharedPreferences dropboxPrefs = getSharedPreferences("com.yoshione.fingen.dropbox", Context.MODE_PRIVATE); String token = dropboxPrefs.getString("dropbox-token", null); try { File zip = DBHelper.getInstance(getApplicationContext()).backupDB(true); if (token != null && zip != null) { new UploadTask(DropboxClient.getClient(token), zip, new IOnComplete() { @Override public void onComplete() { Toast.makeText(ActivityBackup.this, "File uploaded successfully", Toast.LENGTH_SHORT).show(); SharedPreferences preferences = android.support.v7.preference.PreferenceManager.getDefaultSharedPreferences(ActivityBackup.this); preferences.edit().putLong(FgConst.PREF_SHOW_LAST_SUCCESFUL_BACKUP_TO_DROPBOX, new Date().getTime()).apply(); initLastDropboxBackupField(); } }).execute(); } } catch (IOException e) { e.printStackTrace(); } }
Example #10
Source File: MapFragment.java From droidkaigi2016 with Apache License 2.0 | 6 votes |
@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION) void initGoogleMap() { SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(googleMap -> { //noinspection MissingPermission googleMap.setMyLocationEnabled(true); binding.mapSearchView.bindData(placeMapList, placeMap -> { LatLng latLng = new LatLng(placeMap.latitude, placeMap.longitude); int duration = getResources().getInteger(R.integer.map_camera_move_mills); googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng), duration, null); Marker marker = markers.get(placeMap.nameRes); if (marker != null) marker.showInfoWindow(); }); binding.loadingView.setVisibility(View.GONE); googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); googleMap.setIndoorEnabled(true); googleMap.setBuildingsEnabled(true); googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LAT_LNG_CENTER, DEFAULT_ZOOM)); UiSettings mapUiSettings = googleMap.getUiSettings(); mapUiSettings.setCompassEnabled(true); renderMarkers(placeMapList, googleMap); }); }
Example #11
Source File: ActivityBackup.java From fingen with Apache License 2.0 | 6 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void restoreDBFromDropbox() { Thread t = new Thread(new Runnable() { @Override public void run() { SharedPreferences dropboxPrefs = getApplicationContext().getSharedPreferences("com.yoshione.fingen.dropbox", Context.MODE_PRIVATE); String token = dropboxPrefs.getString("dropbox-token", null); List<Metadata> metadataList; List<MetadataItem> items = new ArrayList<>(); try { metadataList = DropboxClient.getListFiles(DropboxClient.getClient(token)); for (int i = metadataList.size() - 1; i >= 0; i--) { if (metadataList.get(i).getName().toLowerCase().contains(".zip")) { items.add(new MetadataItem((FileMetadata) metadataList.get(i))); } } } catch (Exception e) { Log.d(TAG, "Error read list of files from Dropbox"); } mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_DIALOG, items)); } }); t.start(); }
Example #12
Source File: SplashActivity.java From AndroidFrame with Apache License 2.0 | 5 votes |
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) void goToMainPage() { // TODO: 2018/3/6 拿本地cookie判断登录状态,判断是否进行过风险测评已登录且进行过风险测评则显示月投宝,否则显示智能时代 mHandler.postDelayed(new Runnable() { @Override public void run() { Intent intent = new Intent(LQBApp.getApp(), MainActivity.class); startActivity(intent); finish(); } }, 2000); }
Example #13
Source File: MainActivity.java From AndroidBleManager with Apache License 2.0 | 5 votes |
/** * 这个方法中写正常的逻辑(假设有该权限应该做的事) */ @NeedsPermission({Manifest.permission.BLUETOOTH_ADMIN, Manifest.permission.BLUETOOTH, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION ,Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void showCheckPermissionState(){ //检查是否开启位置信息(如果没有开启,则无法扫描到任何蓝牙设备在6.0) if (!LocationUtils.isGpsProviderEnabled(this)){ showOpenLocationSettingDialog(); } }
Example #14
Source File: SelectorActivity.java From UltraGpuImage with MIT License | 5 votes |
@NeedsPermission({ Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE, }) void checkPermission() { ButterKnife.bind(this); }
Example #15
Source File: MainActivity.java From GetApk with MIT License | 5 votes |
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE) public void getApp(Uri uri) { mDialog = new ProgressDialog.Builder(MainActivity.this) .title(R.string.parsing) .show(); mDisposables.add(mPresenter.getApp(MainActivity.this, uri)); }
Example #16
Source File: ScanActivity.java From M365-Power with GNU General Public License v3.0 | 5 votes |
@NeedsPermission(Manifest.permission.ACCESS_COARSE_LOCATION) void startScan() { if ((mBTAdapter != null) && (!mIsScanning)) { mBTAdapter.startLeScan(this); mIsScanning = true; setProgressBarIndeterminateVisibility(true); invalidateOptionsMenu(); } }
Example #17
Source File: MainActivity.java From WheelLogAndroid with GNU General Public License v3.0 | 5 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.WRITE_EXTERNAL_STORAGE}) void toggleLoggingService() { Intent dataLoggerServiceIntent = new Intent(getApplicationContext(), LoggingService.class); if (LoggingService.isInstanceCreated()) stopService(dataLoggerServiceIntent); else startService(dataLoggerServiceIntent); }
Example #18
Source File: SplashActivity.java From RememBirthday with GNU General Public License v3.0 | 5 votes |
@NeedsPermission(Manifest.permission.READ_CONTACTS) public void showRationalForContacts() { Intent intentService = new Intent(this, ContactsProviderIntentService.class); startService(intentService); Intent intent = new Intent(this, BuddyActivity.class); startActivity(intent); finish(); }
Example #19
Source File: HomeActivity.java From Pano360 with MIT License | 5 votes |
@NeedsPermission({ Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.INTERNET }) void init(){ //fake method to require permissions }
Example #20
Source File: ActivityImportCSV.java From fingen with Apache License 2.0 | 5 votes |
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE) void importCSV() { String path = editTextFileName.getText().toString(); File f = new File(path); if (!f.exists()) { Toast.makeText(ActivityImportCSV.this, getString(R.string.msg_file_not_exist), Toast.LENGTH_SHORT).show(); return; } final CsvImporter csvImporter = new CsvImporter(this, path, 0, false); csvImporter.setmCsvImportProgressChangeListener(this); handler.sendMessage(handler.obtainMessage(HANDLER_OPERATION_SHOW, 0, 0)); Thread t = new Thread(new Runnable() { @Override public void run() { try { if (getIntent().getStringExtra("type").equals("fingen")) { csvImporter.loadFingenCSV(); } else { csvImporter.loadFinancistoCSV(); } } catch (IOException e) { e.printStackTrace(); } } }); t.start(); }
Example #21
Source File: ActivityImportCSV.java From fingen with Apache License 2.0 | 5 votes |
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE) void SelectFile() { FileUtils.SelectFileFromStorage(ActivityImportCSV.this, DialogConfigs.FILE_SELECT, new FileUtils.IOnSelectFile() { @Override public void OnSelectFile(String FileName) { editTextFileName.setText(FileName); } }); }
Example #22
Source File: ActivityImportCSVAdvanced.java From fingen with Apache License 2.0 | 5 votes |
@SuppressLint("InlinedApi") @NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE) void importCSV() { String path = editTextFileName.getText().toString(); if (path.isEmpty()) return; final CsvImporter csvImporter = new CsvImporter(getApplicationContext(), path, mSkipLines, false); File f = new File(path); if (!f.exists()) { Toast.makeText(ActivityImportCSVAdvanced.this, getString(R.string.msg_file_not_exist), Toast.LENGTH_SHORT).show(); return; } csvImporter.setmCsvImportProgressChangeListener(this); final ImportParams importParams = mAdapterColumnIndex.getImportParams(); importParams.setDateFormat(csvImporter.detectDateFormat(importParams.date), csvImporter.detectTimeFormat(importParams.time)); handler.sendMessage(handler.obtainMessage(HANDLER_OPERATION_SHOW, 0, 0)); Thread t = new Thread(new Runnable() { @Override public void run() { try { csvImporter.loadCustomCSV(importParams); } catch (IOException e) { e.printStackTrace(); } } }); t.start(); }
Example #23
Source File: FileChooserActivity.java From Mp3Cutter with GNU General Public License v3.0 | 5 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void refreshData(final boolean isforce) { if (mDataBinding.aviLoading.isShown()) return; startLoadingAnim(); mPresenter.loadFile(isforce); }
Example #24
Source File: DetailFilterActivity.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
/** * 开始gif截图 */ @NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) void startGif() { //开始缓存各个帧 mGifCreateHelper.startGif(new File(FileUtils.getPath())); }
Example #25
Source File: ThirdPartyActivity.java From android-advanced-light with MIT License | 5 votes |
@NeedsPermission(Manifest.permission.CALL_PHONE) //在需要获取权限的地方注释 void call() { Intent intent = new Intent(Intent.ACTION_CALL); Uri data = Uri.parse("tel:" + "10086"); intent.setData(data); try { startActivity(intent); } catch (SecurityException e) { e.printStackTrace(); } }
Example #26
Source File: MeFragment.java From CrazyDaily with Apache License 2.0 | 5 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void handleImg() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT) .setType("image/*") .addCategory(Intent.CATEGORY_OPENABLE); String[] mimeTypes = {"image/jpeg", "image/png"}; intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); startActivityForResult(Intent.createChooser(intent, "选择图片"), REQUEST_SELECT_PICTURE); }
Example #27
Source File: ScannerActivity.java From CrazyDaily with Apache License 2.0 | 5 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void handleImg() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT) .setType("image/*") .addCategory(Intent.CATEGORY_OPENABLE); String[] mimeTypes = {"image/jpeg", "image/png"}; intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); startActivityForResult(Intent.createChooser(intent, "选择图片"), REQUEST_SELECT_PICTURE); }
Example #28
Source File: MeFragment.java From CrazyDaily with Apache License 2.0 | 5 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void showFeedback() { new PgyerFeedbackManager.PgyerFeedbackBuilder() //设置是否摇一摇的方式激活反馈,默认为 true .setShakeInvoke(false) //设置以Dialog的方式打开 .setDisplayType(PgyerFeedbackManager.TYPE.DIALOG_TYPE) .builder().invoke(); }
Example #29
Source File: MeActivity.java From CrazyDaily with Apache License 2.0 | 5 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void showFeedback() { new PgyerFeedbackManager.PgyerFeedbackBuilder() //设置是否摇一摇的方式激活反馈,默认为 true .setShakeInvoke(false) //设置以Dialog的方式打开 .setDisplayType(PgyerFeedbackManager.TYPE.DIALOG_TYPE) .builder().invoke(); }
Example #30
Source File: MeActivity.java From CrazyDaily with Apache License 2.0 | 5 votes |
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}) void handleImg() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT) .setType("image/*") .addCategory(Intent.CATEGORY_OPENABLE); String[] mimeTypes = {"image/jpeg", "image/png"}; intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes); startActivityForResult(Intent.createChooser(intent, "选择图片"), REQUEST_SELECT_PICTURE); }