当前位置: 首页>>代码示例>>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;未经允许,请勿转载。