相关疑难解决方法(0)

Android marshmallow请求权限?

我目前正在开发一个需要几个"危险"权限的应用程序.因此,我尝试在Android Marshmallow(API级别23)中添加"请求许可",但无法找到如何执行此操作.

如何在我的应用中使用新的权限模型请求权限?

android android-permissions android-6.0-marshmallow

151
推荐指数
8
解决办法
24万
查看次数

android.permission.BIND_TELECOM_CONNECTION_SERVICE 权限被拒绝

我想为 Voip 拨号器应用程序实现“android.telephony”库。因此,根据此https://developer.android.com/reference/android/telecom/ConnectionService我正在尝试注册 PhoneAccount。我正在做如下,

private void registerPhoneAcc(String calleeURI, String phoneNumber) {
       
        TelecomManager telecomManager = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            telecomManager = (TelecomManager) getContext().getSystemService(Context.TELECOM_SERVICE);
        }
        ComponentName componentName = new ComponentName(getContext().getPackageName(), String.valueOf(MyConnectionService.class));
        PhoneAccountHandle phoneAccountHandle = null;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            phoneAccountHandle = new PhoneAccountHandle(componentName,"App" );
            PhoneAccount phoneAccount = PhoneAccount.builder(phoneAccountHandle, "Primary").setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER).build();
            telecomManager.registerPhoneAccount(phoneAccount);
        }
       
    }
Run Code Online (Sandbox Code Playgroud)
<service android:name=".app.MyConnectionService"
            android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE">
            <intent-filter>
                <action android:name="android.telecom.ConnectionService" />
            </intent-filter>
        </service>
Run Code Online (Sandbox Code Playgroud)

尽管我已经包含了许可,但我遇到了以下异常

W/System.err: java.lang.SecurityException: PhoneAccount connection service requires BIND_TELECOM_CONNECTION_SERVICE permission.
2021-02-03 13:58:39.259 24630-24630/com.ex.voip W/System.err:     at android.os.Parcel.readException(Parcel.java:2013)
2021-02-03 …
Run Code Online (Sandbox Code Playgroud)

android voip telephony android-connectionservice

5
推荐指数
0
解决办法
2783
查看次数

尝试保存位图图像时始终出现“权限被拒绝”或“没有此类文件或目录”的情况。我应该怎么办?

我正在尝试通过以下代码保存位图图像:

File sdcard = Environment.getExternalStorageDirectory();
            String filename = "test";
            File folder = new File(sdcard, "/Download");
            Log.v("ImageStorage1", "EXiST?: " + folder.exists());
            folder.mkdirs();
            Log.v("ImageStorage2", "EXIST!: " + folder.exists());
            Log.v("ImageStorage", "Folder: " + folder);
            File file = new File(folder, filename + ".jpg");

            try {
                FileOutputStream out = new FileOutputStream(file.getAbsoluteFile());
                result.compress(Bitmap.CompressFormat.JPEG, 90, out);
                out.flush();
                out.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
Run Code Online (Sandbox Code Playgroud)

我还在清单文件中使用:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Run Code Online (Sandbox Code Playgroud)

但我得到了这个:

V/ImageStorage1: EXiST?: true
V/ImageStorage2: EXIST!: true
W/System.err: java.io.FileNotFoundException: 
/storage/emulated/0/Download/test.jpg (Permission denied)
    W/System.err:     at java.io.FileOutputStream.open0(Native Method)
    W/System.err:     at java.io.FileOutputStream.open(FileOutputStream.java:287) …
Run Code Online (Sandbox Code Playgroud)

android filenotfoundexception permission-denied

-1
推荐指数
1
解决办法
1417
查看次数