2016-06-08 1 views
1

여기에 약간의 문제가있어 그것이 나를 미치게합니다. 돈 파편 때문에,Android 조각에서 호출 할 때 권한 거부. 사용 권한이 설정 됨

Intent callIntent = new Intent(Intent.ACTION_CALL); 
     Ansat a = container.adapter.getItem(position); 
     callIntent.setData(Uri.parse("tel:" + a.mobil.replace(" ", "").trim())); 
     container.startActivity(callIntent); 

컨테이너이 조각에 전달 된 주요 활동 컨텍스트입니다 : 나는 안드로이드에 ACTION_CALL 의도로 사람을 호출 할 나는 조각에 다음 코드와 함께 할 그 자체의 활동이 있습니다. 이후 OS를 안드로이드 6.0에서

FATAL EXCEPTION: main 
     Process: mithfogvuc.android.svhfvuc.dk, PID: 23045 
     java.lang.SecurityException: Permission Denial: starting Intent { 
     act=android.intent.action.CALL dat=tel:xxxxxxxx cmp=com.android.server.telecom/.components.UserCallActivity } 
     from ProcessRecord{6c1ee2e 23045:mithfogvuc.android.svhfvuc.dk/u0a251} (pid=23045, uid=10251) with revoked permission android.permission.CALL_PHONE 
+0

포스트 안드로이드 매니페스트 같이 수행 할 수 있습니다. – Sush

+0

전체 매니페스트가있는 경우 – MartinMojito

+0

어떤 OS 버전입니까? –

답변

2

(23 LVL API) :

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.SEND_SMS" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<uses-permission android:name="android.permission.CALL_PHONE" /> 

<permission 
    android:name="mithfogvuc.android.svhfvuc.dk.app.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 

<uses-permission android:name="mithfogvuc.android.svhfvuc.dk.app.permission.C2D_MESSAGE" /> 

<uses-feature 
    android:name="android.hardware.camera" 
    android:required="true" /> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme.NoActionBar" 
    tools:replace="android:icon"> 
    <activity 
     android:name=".SplashActivity" 
     android:screenOrientation="portrait"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity 
     android:name=".MainActivity" 
     android:screenOrientation="portrait" /> 
    <activity 
     android:name=".NewsActivity" 
     android:screenOrientation="portrait" /> 

    <receiver 
     android:name="com.google.android.gms.gcm.GcmReceiver" 
     android:exported="true" 
     android:permission="com.google.android.c2dm.permission.SEND"> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 

      <category android:name="mithfogvuc.android.svhfvuc.dk.app" /> 
     </intent-filter> 
    </receiver> 

    <service 
     android:name=".GCMPushReceiverService" 
     android:exported="false"> 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
     </intent-filter> 
    </service> 
    <service 
     android:name=".GCMRegistrationIntentService" 
     android:exported="false"> 
     <intent-filter> 
      <action android:name="com.google.android.gms.idd.InstanceID" /> 
     </intent-filter> 
    </service> 

    <activity 
     android:name=".FravaersregistreringActivity" 
     android:screenOrientation="portrait" /> 
    <activity 
     android:name=".FremmoederegistreringActivity" 
     android:screenOrientation="portrait"/> 
</application> 

가 왜 나는 다음과 같은 오류가 점점 오전 :

나는 안드로이드 매니페스트 권한을 설정 한 사용자는 을 응용 프로그램의 사용 권한 인에서 취소 할 수 있습니다. 살펴 봐야합니다 Runtime Permissions

call_phone API에 대한 액세스 권한을 부여 받기 위해 앱이 requestPermissions() 방법 중 하나를 폴링해야합니다.

0

당신이

   if (ContextCompat.checkSelfPermission(getActivity(), 
          android.Manifest.permission.CALL_PHONE) 
          != PackageManager.PERMISSION_GRANTED) { 

         // Should we show an explanation? 
         if 

      (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), 
           android.Manifest.permission.CALL_PHONE)) { 

          // Show an expanation to the user *asynchronously* -- don't block 
          // this thread waiting for the user's response! After the user 
          // sees the explanation, try again to request the permission. 

          Toast.makeText(getActivity(),"Its Necessary To Call",Toast.LENGTH_LONG).show(); 

          ActivityCompat.requestPermissions(getActivity(), 
            new String[]  {Manifest.permission.CALL_PHONE}, 
            MY_PERMISSIONS_REQUEST_CALL_PHONE); 

         } else { 

          // No explanation needed, we can request the  permission. 

          ActivityCompat.requestPermissions(getActivity(), 
            new String[] {Manifest.permission.CALL_PHONE}, 
            MY_PERMISSIONS_REQUEST_CALL_PHONE); 

          // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an 
          // app-defined int constant. The callback method gets the 
          // result of the request. 
         } 
        }else{ 
         Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number)); 
         startActivity(intent); 

        }