當前位置: 首頁>>代碼示例>>Java>>正文


Java NeedsPermission類代碼示例

本文整理匯總了Java中permissions.dispatcher.NeedsPermission的典型用法代碼示例。如果您正苦於以下問題:Java NeedsPermission類的具體用法?Java NeedsPermission怎麽用?Java NeedsPermission使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NeedsPermission類屬於permissions.dispatcher包,在下文中一共展示了NeedsPermission類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: chooseFile

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission({Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE})
public void chooseFile(Intent dataIntent) {
    /* Check for network connectivity */
    if (isConnectedToActiveNetwork(this)) {
        // if upload was chosen from the app
        if (dataIntent == null) {
            // Use system file browser
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
            intent.setType("*/*");
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(Intent.createChooser(intent, "Choose the file to Upload.."), INTENT_FILE_REQUEST);

        } else {
            // If Intent received from implicit intent
            onActivityResult(INTENT_FILE_REQUEST, RESULT_OK, dataIntent);
        }
    } else {
        /* Show no network dialog */
        NoNetworkDialogFragment noNetworkDialogFragment = new NoNetworkDialogFragment();
        noNetworkDialogFragment.show(getSupportFragmentManager(), getString(R.string.no_net_dialog_fragment_tag));
    }
}
 
開發者ID:rumaan,項目名稱:file.io-app,代碼行數:23,代碼來源:MainActivity.java

示例2: takeAPhoto

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission({Manifest.permission.CAMERA})
void takeAPhoto() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) {
        Observable.just(this)
                .observeOn(Schedulers.newThread())
                .map((ctx) -> presenter.createImageFile(this))
                .subscribe(photoFile -> {
                    Timber.d(Thread.currentThread().getName());
                    if (photoFile != null) {
                        Uri photoURI = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID
                                + ".provider", presenter.createImageFile(this));
                        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                        startActivityForResult(takePictureIntent, TAKE_PHOTO);
                    }
                }, t -> onLocationError());
    }
}
 
開發者ID:BANKEX,項目名稱:smart-asset-iot-android-demo,代碼行數:19,代碼來源:MainActivity.java

示例3: setupHttpCachingTileServer

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
// Must be public to use PermissionsDispatcher
public void setupHttpCachingTileServer() {
    final String tag = "setupHttpCachingTileServer - ";
    final HttpCacheTileServer httpCacheTileServer = HttpCacheTileServer.getInstance();
    httpCacheTileServer.init(getActivity(), SettingsUtils.getInstance().parseFromPreferencesMapCacheDiskUsageMax());

    if (httpCacheTileServer.startServer()){
        // Server in place, load page

        final String url="file:///android_asset/index.html";
        if (webView.getUrl()==null || webView.getUrl().isEmpty() || !webView.getUrl().equalsIgnoreCase(url)) {
            webView.loadUrl("file:///android_asset/index.html");
            // Flow will resume at: onPageFinished
        }
    }
}
 
開發者ID:videgro,項目名稱:Ships,代碼行數:18,代碼來源:ShowMapFragment.java

示例4: setupLocationService

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)
// Must be public to use PermissionsDispatcher
public void setupLocationService() {
    final String tag="setupLocationService - ";
    if (isAdded()) {
        final Activity activity=getActivity();
        if (activity!=null){
            locationServiceConnection = new LocationServiceConnection((OwnLocationReceivedListener) this);
            Intent serviceIntent = new Intent(activity,TrackService.class);
            activity.startService(serviceIntent);
            activity.bindService(new Intent(activity,TrackService.class), locationServiceConnection, Context.BIND_AUTO_CREATE);
        } else {
            Log.e(TAG,tag+"Activity is null.");
        }
    }
}
 
開發者ID:videgro,項目名稱:Ships,代碼行數:17,代碼來源:ShowMapFragment.java

示例5: onInsertImageUploadClicked

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@SuppressLint("InlinedApi") // suppressed because PermissionsDispatcher handles API levels for us
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
public void onInsertImageUploadClicked(Action1<String> uploadDoneAction) {
    mImageUploadDoneAction = uploadDoneAction;
    Intent imagePickIntent = new Intent(Intent.ACTION_GET_CONTENT);
    imagePickIntent.addCategory(Intent.CATEGORY_OPENABLE);
    imagePickIntent.setType("image/*");
    if (imagePickIntent.resolveActivity(mActivity.getPackageManager()) != null) {
        startActivityForResult(imagePickIntent, REQUEST_CODE_IMAGE_PICK);
    } else {
        Toast.makeText(mActivity, R.string.intent_no_apps, Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:14,代碼來源:PostEditFragment.java

示例6: loadArtworkView

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
public void loadArtworkView(final EMPlaylistManager.PlaylistItem currentItem) {
    picasso.load(currentItem.getArtworkUrl()).transform(new BlurTransformer(currentItem.getArtworkUrl())).into(artworkView, new Callback() {
        @Override
        public void onSuccess() {
            RotateAnimation ra = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
            ra.setRepeatMode(Animation.INFINITE);
            ra.setRepeatCount(Animation.INFINITE);
            ra.setDuration(12000l);
            ra.setInterpolator(new LinearInterpolator());
            artworkView.startAnimation(ra);
        }

        @Override
        public void onError() {

        }
    });

}
 
開發者ID:DroidKOF,項目名稱:pineapple,代碼行數:21,代碼來源:AudioPlayerActivity.java

示例7: onUpdateAvailable

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission({
    Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE,
    Manifest.permission.RECORD_AUDIO
}) void checkUpdate() {
    //PgyUpdateManager.register(getActivity(), getString(R.string.file_provider));
    PgyUpdateManager.register(getActivity(), getString(R.string.file_provider),
        new UpdateManagerListener() {
            @Override public void onUpdateAvailable(final String result) {
                // 將新版本信息封裝到AppBean中
                final AppBean appBean = getAppBeanFromString(result);
                new AlertDialog.Builder(getActivity()).setTitle("更新")
                    .setMessage(appBean.getReleaseNote())
                    .setNegativeButton("取消", null)
                    .setPositiveButton("下載", new DialogInterface.OnClickListener() {
                        @Override public void onClick(DialogInterface dialog, int which) {
                            startDownloadTask(getActivity(), appBean.getDownloadURL());
                        }
                    })
                    .show();
            }

            @Override public void onNoUpdateAvailable() {
                ToastUtil.showText(getActivity(), "已經是最新版本了");
            }
        });
}
 
開發者ID:plusend,項目名稱:DiyCode,代碼行數:27,代碼來源:SettingsFragment.java

示例8: startCollectorService

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission({Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.READ_PHONE_STATE})
void startCollectorService() {
    Log.d("startCollectorService(): Air plane mode off, starting service");
    // create intent
    final Intent intent = new Intent(this, CollectorService.class);
    // pass means of transport inside intent
    boolean gpsOptimizationsEnabled = MyApplication.getPreferencesProvider().getGpsOptimizationsEnabled();
    MeansOfTransport selectedType = (gpsOptimizationsEnabled ? MeansOfTransport.Universal : MeansOfTransport.Fixed);
    intent.putExtra(CollectorService.INTENT_KEY_TRANSPORT_MODE, selectedType);
    // pass screen on mode
    final String keepScreenOnMode = MyApplication.getPreferencesProvider().getCollectorKeepScreenOnMode();
    intent.putExtra(CollectorService.INTENT_KEY_KEEP_SCREEN_ON_MODE, keepScreenOnMode);
    // start service
    ApkUtils.startServiceSafely(this, intent);
    EventBus.getDefault().post(new CollectorStartedEvent(intent));
    MyApplication.getAnalytics().sendCollectorStarted(IntentSource.User);
}
 
開發者ID:zamojski,項目名稱:TowerCollector,代碼行數:18,代碼來源:MainActivity.java

示例9: dispatchHandleAttachmentLink

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
public void dispatchHandleAttachmentLink(SubjectReport report) {
  File baseDir =
      new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
          "E-class");

  if (!baseDir.exists() && !baseDir.mkdirs()) {
    throw new RuntimeException("No access to storage");
  }

  File destination = new File(baseDir, report.getName());

  Intent intent = new Intent(this, AttachmentDownloaderService.class);
  intent.putExtra(AttachmentDownloaderService.EXTRA_ASSIGNMENT_SUBJECT, report);
  intent.putExtra(AttachmentDownloaderService.EXTRA_DESTINATION, destination.getPath());
  this.startService(intent);
}
 
開發者ID:ozodrukh,項目名稱:IUT-E-class,代碼行數:18,代碼來源:MainActivity.java

示例10: prepareSending

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
/**
 * 檢查VPN連接,並發送
 */
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
void prepareSending(final int resId) {
    if (NetworkUtil.isVpnEnabled()) {
        new AlertDialog.Builder(this)
                .setTitle(getString(R.string.dialog_vpn_title))
                .setMessage(getString(R.string.dialog_vpn_message))
                .setPositiveButton(getString(R.string.dialog_vpn_button_close), null)
                .setNegativeButton(getString(R.string.dialog_vpn_button_ignore), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        sendFile(resId);
                    }
                })
                .show();
    } else {
        sendFile(resId);
    }
}
 
開發者ID:YieldNull,項目名稱:Biu,代碼行數:22,代碼來源:ShareActivity.java

示例11: initGoogleMap

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@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);
    });
}
 
開發者ID:konifar,項目名稱:droidkaigi2016,代碼行數:26,代碼來源:MapFragment.java

示例12: startLocationUpdates

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@SuppressWarnings("MissingPermission")
@NeedsPermission({Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION})
void startLocationUpdates() {
    if (!isLocationPermissionsGranted()) {
        return;
    }
    locationManager.startLocationUpdates(!isLocationSettingsCheckAsked);
    isLocationSettingsCheckAsked = true;
}
 
開發者ID:BANKEX,項目名稱:smart-asset-iot-android-demo,代碼行數:10,代碼來源:MainActivity.java

示例13: call

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@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();
        }
    }
 
開發者ID:henrymorgen,項目名稱:android-advanced-light,代碼行數:13,代碼來源:ThirdPartyActivity.java

示例14: showCheckPermissionState

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
/**
 * 這個方法中寫正常的邏輯(假設有該權限應該做的事)
 */
@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();
    }
}
 
開發者ID:Twelvelines,項目名稱:AndroidMuseumBleManager,代碼行數:13,代碼來源:MainActivity.java

示例15: startService

import permissions.dispatcher.NeedsPermission; //導入依賴的package包/類
@NeedsPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
public void startService() {
    serviceRunning = true;
    plSwitch.start();
    startService(new Intent(this, ClipboardService.class));
    showAlert(R.string.message_service_enabled, R.color.colorAlertGreen, R.drawable.ic_check,
            Constants.DURATION_SHORT);
}
 
開發者ID:vshkl,項目名稱:SaveIg,代碼行數:9,代碼來源:MainActivity.java


注:本文中的permissions.dispatcher.NeedsPermission類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。