Giter Club home page Giter Club logo

tedpermission's Introduction

Android Arsenal

What is TedPermission?

After the update to Android 6.0 Marshmallow, we have to not only declare permissions in AndroidManifest.xml, but also request them at runtime. Furthermore, the user can turn permissions on/off anytime in application settings.
When you use dangerous permissons(ex. CAMERA, READ_CONTACTS, READ_PHONE_STATE, ...), you must check and request them at runtime.
(https://developer.android.com/guide/topics/permissions/overview?hl=en#normal-dangerous)

You can make your own permission check logic like this, but it's very complex, mainly because functions Google offer are very hard to use: checkSelfPermission(), requestPermissions(), onRequestPermissionsResult(), onActivityResult().

TedPermission makes it easy to check and request android permissions.

(For Korean) 아래 블로그를 통해 마시멜로우 권한 관련된 사항을 알아보세요
http://gun0912.tistory.com/55

Demo



Screenshot

  1. Request permissions.
  2. If user denied permissions, a message dialog with a button to go to Settings will appear.

Setup

  • Edit root/app/build.gradle like below.
  • You can choose only one library depend on your code style normal/coroutine/rxJava2/rxJava3
  • Replace x.y.z with the version shown in the 'Maven Central' button below, or the specific version you want (e.g. replace x.y.z with 3.4.2 if you want 3.4.2).

Maven Central

repositories {
  google()
  mavenCentral()
}

dependencies {
    // Normal
    implementation("io.github.ParkSangGwon:tedpermission-normal:3.4.2")
    
    // Coroutine
    implementation("io.github.ParkSangGwon:tedpermission-coroutine:3.4.2")

    // RxJava2
    implementation("io.github.ParkSangGwon:tedpermission-rx2:3.4.2")
    // RxJava3
    implementation("io.github.ParkSangGwon:tedpermission-rx3:3.4.2")
}

If you think this library is useful, please press the star button at the top.



How to use

Normal

-Make PermissionListener

We will use PermissionListener for handling permission check result. You will get the result to onPermissionGranted() or onPermissionDenied() depending on approved permissions.

    PermissionListener permissionlistener = new PermissionListener() {
        @Override
        public void onPermissionGranted() {
            Toast.makeText(MainActivity.this, "Permission Granted", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onPermissionDenied(List<String> deniedPermissions) {
            Toast.makeText(MainActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show();
        }


    };

-Start TedPermission

TedPermission class requires setPermissionListener(), setPermissions(), and check() methods. Call check() to start checking for permissions.

setRationaleMessage() and setDeniedMessage() are optional methods for displaying messages.

    TedPermission.create()
        .setPermissionListener(permissionlistener)
        .setDeniedMessage("If you reject permission,you can not use this service\n\nPlease turn on permissions at [Setting] > [Permission]")
        .setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.ACCESS_FINE_LOCATION)
        .check();



Coroutine

If you use kotlin and coroutine, You can use check()function. TedPermissionResult instance has isGranted(), getDeniedPermissions() methods for checking permission check result.

val permissionResult =
    TedPermission.create()
        .setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.ACCESS_FINE_LOCATION)
        .check()

Also if you want know only granted result, you can use checkGranted(): boolean

RxJava

If you use RxJava, You can use request() method instead check(). When permission check has finished, you will receive TedPermissionResult instance. TedPermissionResult instance has isGranted(), getDeniedPermissions() methods for checking permission check result.

    TedPermission.create()
        .setRationaleTitle(R.string.rationale_title)
        .setRationaleMessage(R.string.rationale_message) // "we need permission for read contact and find your location"
        .setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.ACCESS_FINE_LOCATION)
        .request()
        .subscribe(tedPermissionResult -> {
          if (tedPermissionResult.isGranted()) {
            Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show();
          } else {
            Toast.makeText(this,
                "Permission Denied\n" + tedPermissionResult.getDeniedPermissions().toString(), Toast.LENGTH_SHORT)
                .show();
          }
        }, throwable -> {
        });

Customize

TedPermission supports the following methods.

  • setGotoSettingButton(boolean) (default: true)
  • setRationaleTitle(R.string.xxx or String)
  • setRationaleMessage(R.string.xxx or String)
  • setRationaleConfirmText(R.string.xxx or String) (default: confirm / 확인)
  • setDeniedTitle(R.string.xxx or String)
  • setDeniedMessage(R.string.xxx or String)
  • setDeniedCloseButtonText(R.string.xxx or String) (default: close / 닫기)
  • setGotoSettingButtonText(R.string.xxx or String) (default: setting / 설정)

Also you can use the following utility functions.

  • isGranted(String... permissions): Check if all permissions are granted
  • isDenied(String... permissions): Check if all permissions are denied
  • getDeniedPermissions(String... permissions)
  • canRequestPermission(Activity activity, String... permissions): If true you can request a system popup, false means user checked Never ask again.
  • startSettingActivityForResult()
  • startSettingActivityForResult(int requestCode)



Number of Cases

  1. Check permissions -> Already have permissions
    : onPermissionGranted() is called.

  2. Check permissions -> Don't have permissions
    : Request dialog is shown.
    Screenshot

  3. Show request dialog -> User granted permissions
    : onPermissionGranted() is called.

  4. Show request dialog -> User denied one or more permissions
    : Denied dialog is shown.
    Screenshot

  5. Show denied dialog -> Close the dialog
    : onPermissionDenied() called

  6. Show denied dialog -> Setting button clicked
    : startActivityForResult() to application Setting Activity.
    Screenshot

  7. Setting Activity -> onActivityResult()
    : Check permissions again

  8. Check permission -> Permissions are granted
    : onPermissionGranted() is called.

  9. Check permission -> There are denied permissions
    : onPermissionDenied() is called.



Screenshot



License

Copyright 2021 Ted Park

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

tedpermission's People

Contributors

b1uec0in avatar boxresin avatar dotkebi avatar dwkim-sugarhill avatar ema987 avatar floweryk avatar gun0912 avatar heywon0909 avatar jspiner avatar kakao-noah-kim avatar minsik-ai avatar parksanggwon avatar ted-prnd avatar wahibhaq avatar yjbae-sk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tedpermission's Issues

Appcomat 테마 오류요.

48:00.252 29302-29302/com.test.permission E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.test.permission, PID: 29302
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.permission/com.test.permission.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2434)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
at android.app.ActivityThread.access$900(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5527)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:331)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:264)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.test.permission.MainActivity.onCreate(MainActivity.java:24)
at android.app.Activity.performCreate(Activity.java:6272)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494) 
at android.app.ActivityThread.access$900(ActivityThread.java:157) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5527) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 

아래 외국인분이 쓰신 오류랑 똑같이 나네요.

테마를 Appcomat 안쓰면 위와 같이 오류가 납니다.

AndroidManifest.xml에서 테마를 노 타이틀바를 주고 테스트 해보시면 됩니다.






targetSdkVersion 22인 경우에는?

우선 멋진 라이브러리 너무너무 감사드립니다....^^;
블로그에도 코멘트를 남기긴 했지만,,,,,

  1. 앱이 설치된 기기는 마시멜로우 이상이고, 설치된 앱의 targetSdkVersion 22인 경우에는
    TedPermission을 활용할 수 없는건가요?

기기의 OS버전이 마시멜로우 이상(또는 누가)인 경우에는 사용자가 언제나 앱 권한을 설정/해제할수 있기에
targetSdkVersion 22를 유지한체, 앱 권한 체크를 하고 싶은데 가능한건지 알고 싶습니다.

  1. 이 라이브러리를 사용하기 위해서는 SYSTEM_ALERT_WINDOW 권한이 꼭 필요한건가요?

질문 게시판이 아님에도 질문만을 올려서 문제가 된다면 죄송합니다...

Unable to find explicit activity class

Hello i have already read the previous issue nut i am consider if i am missing something. I use in manifest tools:node="replace" and when i change replace with merge i get this error :
Error:Execution failed for task ':app:processDebugManifest'.

Manifest merger failed with multiple errors, see logs.
Also i have multiDexEnabled true in grandle file.
Any idea?

android.permission.PACKAGE_USAGE_STATS

안녕하세요! TedPermission으로 앱을 개발하고 있는데요,
제 앱에서 android.permission.PACKAGE_USAGE_STATS 권한이 필요한데,
이 권한도 android.permission.SYSTEM_ALERT_WINDOW 처럼 기존 퍼미션과 다른 방법으로 허용을 해줘야 하더라구요.

제가 직접 수정해보려고 시도했으나 (https://github.com/Darkhost/TedPermission)
무엇이 문제인지 제대로 작동을 하지 않네요..

혹시라도 여유가 되신다면 해당 퍼미션도 기능 추가를 해주셨으면 합니다.

다이얼로그가 안뜨는문제.

안드로이드 이제막 공부를 시작하는 초보생인데, 궁금증이 생겨서 여기에 질문을 드려도되는지 몰르겠지만. 혹시나해서 여쭈어봅니당..
new TedPermission(getActivity())
.setPermissionListener(permissionlistener)
.setRationaleMessage("이 기능을 사용하기 위해서는 단말기의 "전화걸기 및 관리" " +\n" +
"// "권한이 필요합니다. 계속하시겠습니까?")
.setDeniedMessage("앱 실행을 위해서는 전화 관리 권한을 " +\n" +
"// "설정해야 합니다"")
.setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.CALL_PHONE)
.check();

제가 이런식으로 설정하고 어플리케이션을 실행하면 권한설정을 하는 대화상자? 이게 떠야되는데 그게 안뜨고 바로 setRationaleMessage에 설정한 내용이 뜨는데 뭐가문제인건가요..?ㅠㅠ.

Soft Key board not open in Whole App

Sometime when we apply TedPermission in the application, soft keyboard not open. And When we comment the code of TedPermission, it's working fine.

I use this library in my 4 application. Issue raise in 2 application another 2 application working properly.

I don't know why this issue occurs because of some permission issue ?

Please help.

@ParkSangGwon can you please help...???

AppCompat 에러 질문입니다.

04-04 17:21:04.546 18876-18990 E/ACRA: com.cocoa_studio.doznut fatal error : Unable to start activity ComponentInfo{com.cocoa_studio.doznut/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cocoa_studio.doznut/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:351)
at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:320)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:281)
at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:83)
at android.support.v7.app.AlertController.installContent(AlertController.java:214)
at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:258)
at android.app.Dialog.dispatchOnCreate(Dialog.java:394)
at android.app.Dialog.show(Dialog.java:295)
at android.support.v7.app.AlertDialog$Builder.show(AlertDialog.java:956)
at com.gun0912.tedpermission.TedPermissionActivity.showRationaleDialog(TedPermissionActivity.java:251)
at com.gun0912.tedpermission.TedPermissionActivity.checkPermissions(TedPermissionActivity.java:196)
at com.gun0912.tedpermission.TedPermissionActivity.onCreate(TedPermissionActivity.java:65)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

보면 오히려 테드퍼미션에서 다이얼로그를 생성할때 에러가 나던데
이유가 뭔지 알 수 있을까요??
우선 최대한 비슷한 환경을 만들기 위해서 테스트앱에 있는
앱테마를 가져다가 사용했습니다.
그런데 제앱에서는 저런에러가 나네요 ㅠㅠ

"ACCESS_FINE_LOCATION"

ACCCESS_COARSE_LOCATION 는 잘되는데

ACCESS_FINE_LOCATION 이건 안되네요

블로그에는 Dangerous permissions 에 관해서 표가 있었는데

거기에 ACCESS_FINE_LOCATION 이것이 포함 되어있어서요.

넣고 돌렸을나 항상 DeniedMassage 만 출력 되는거 같네요.

구글에서 발표한 ACCESS_FINE_LOCATION 사용 변경에 대한 내용에 영향이 있는걸까요?

setDeniedMessage 작동 버그 같습니다.

new TedPermission(context).setDeniedMessage(getString(R.string.message)) 이럴경우 정상적으로
다이어로그 메시지가 뜨는데

new TedPermission(context).setDeniedMessage(R.string.message) 이렇게 했을경우 다이어로그가 뜨지 않고 onPermissionDenied 으로 넘어가 버립니다. 그래서 권한 설정을 할수 없게 됩니다.

Unable to find explicit activity class com.gun0912.tedpermission.TedPermissionActivity

Hello, I use this on my Apps, but i get error
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.android/com.gun0912.tedpermission.TedPermissionActivity}; have you declared this activity in your AndroidManifest.xml

I used any Library. This problem occurs when the added tools: node = "replace" on the manifest, but if it is removed, I get an error manifest merge failed

so how to fix it ?

Blank Activity Animation shows my app_name

When I request permission with TedPermission, the dialog is showed in my activity. The dialog is showing from bottom to top... In this situation, @string/app_name is showed in the middle of the screen. So, I can see @string/app_name in a short time. It makes me feel somthing :( Can you remove the animation of the dialog or remove the text? Thanks!

In Korean,
권한을 요청하는 다이얼로그 창이 뜰때, 다이얼로그 창이 아래에서 위로 올라오는데요... 화면 중간에 app_name이 뜹니다. app_name이 그래서 잠깐 보이는데, 다소 신경쓰이네요 ㅠㅠㅠㅠ dialog창이 뜰 때 app_name이 뜨지 않게 바꿔주실 수 있을까요? 감사합니다.

AppCompat Theme 오류

안녕하세요? 질문이 있어서 올립니다. 에러 로그는 아래와 같습니다.
Unable to start activity ComponentInfo{com.myapp/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

tedpermission을 하는 Activity에서는 별도로 AppCompat를 사용하지 않는데 에러코드가 뜹니다.
어떻게 해결하면 좋을까요? 답변 부탁드리겠습니다.

java.lang.NullPointerException: Attempt to get length of null array

Hi,

I am seeing an app crash which is related to TedPermission library. I could see the following stack traces in my bug tracking system which occurs in Samsung devices like samsung SM-J700F, samsung SM-N910C, samsung SM-J710F, samsung SM-J700H, samsung SM-G900F, samsung SM-G935F, samsung SM-A500F, samsung SM-J500H which runs on 6.0.1.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.miragestacks.thirdeye/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.NullPointerException: Attempt to get length of null array
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at com.gun0912.tedpermission.TedPermissionActivity.void checkPermissions(boolean)(SourceFile:127)
at com.gun0912.tedpermission.TedPermissionActivity.void onCreate(android.os.Bundle)(SourceFile:57)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
... 9 more

EXTERNAL_STORAGE 권한 사용시

Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE

2가지를 우선 넣고 테스트를 하고 있는데요. 다이얼로그 뜨는 순서가 이상합니다.

  1. EXTERNAL_STORAGE 권한 요청 다이얼로그
  2. RationaleMessage다이얼로그
  3. EXTERNAL_STORAGE 권한 요청 다이얼로그

EXTERNAL_STORAGE 권한 요청 다이얼로그가 2번 뜨는 현상이 나오는데 혹시 저만 이런건가요?

난독화는 성공했는데 콜백을 불러오질 못합니다.

proguard적용 난독화하여 apk파일까진 생성됐으나,
PermissionListener가 제대로 작동하지 않아 onPermissionGranted함수를 불러오질 못합니다.
마시멜로우 버전에서 그러네요.

갓상권 블로그 정말 잘이용하고있고 많은 도움됐습니다.
응원합니다 화이팅!

Obfuscate

When use TedPermission in my project and obfuscate my project, I have a crash

Remove colorAccent from your library

Please, remove colorAccent parameter from your library. I have this parameter defined in my app and it conflicts with your definition!

Error:(264, -1) Gradle: Attribute "colorAccent" has already been defined

Generally, it would be nice to remove all v7 dependencies. Instead of:

import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;

use

import android.app.Activity;
import android.app.AlertDialog;

/tedpermission/src/main/res/values/styles.xml change to one string:

<style name="Theme.Transparent" parent="@android:style/Theme.NoTitleBar.Fullscreen"/>

And change /tedpermission/build.gradle from

compile 'com.android.support:appcompat-v7:23.1.1'

to

compile 'com.android.support:appcompat-v4:23+'

null object reference

I encountered the following error on version 1.0.0.

  1. I look at the previous version of the user's question, there is a similar problem, this problem is the old version of the bug?
  2. This problem is in my application is occasional, the first installation start probability is relatively high.
  3. If it is your sdk problem, please reply to my explanation in that version of the solution.

Thank you, hope to reply as soon as possible.

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=10, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } (has extras) }} to activity {com.ion.Apollo/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.RuntimeException: Could not dispatch event: class com.gun0912.tedpermission.busevent.TedPermissionEvent to handler [EventHandler public void com.gun0912.tedpermission.TedInstance.onPermissionResult(com.gun0912.tedpermission.busevent.TedPermissionEvent)]: Attempt to invoke interface method 'android.content.Context com.ion.Apollo.presenter.capture.CapturePresenter$View.getApplicationContext()' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:4520) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4563) at android.app.ActivityThread.-wrap22(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1698) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) Caused by java.lang.RuntimeException: Could not dispatch event: class com.gun0912.tedpermission.busevent.TedPermissionEvent to handler [EventHandler public void com.gun0912.tedpermission.TedInstance.onPermissionResult(com.gun0912.tedpermission.busevent.TedPermissionEvent)]: Attempt to invoke interface method 'android.content.Context com.ion.Apollo.presenter.capture.CapturePresenter$View.getApplicationContext()' on a null object reference at com.squareup.otto.Bus.throwRuntimeException(Bus.java:460) at com.squareup.otto.Bus.dispatch(Bus.java:387) at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:368) at com.squareup.otto.Bus.post(Bus.java:337) at com.gun0912.tedpermission.busevent.TedBusProvider.post(TedBusProvider.java:49) at com.gun0912.tedpermission.TedPermissionActivity.permissionGranted(TedPermissionActivity.java:115) at com.gun0912.tedpermission.TedPermissionActivity.onRequestPermissionsResult(TedPermissionActivity.java:208) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7460) at android.app.Activity.dispatchActivityResult(Activity.java:7286) at android.app.ActivityThread.deliverResults(ActivityThread.java:4516) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4563) at android.app.ActivityThread.-wrap22(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1698) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) Caused by java.lang.NullPointerException: Attempt to invoke interface method 'android.content.Context com.ion.Apollo.presenter.capture.View.getApplicationContextCapturePresenter$()' on a null object reference at com.ion.Apollo.presenter.capture.CapturePresenterImpl.initLocation(CapturePresenterImpl.java:448) at com.ion.Apollo.presenter.capture.CapturePresenterImpl$1.onPermissionGranted(CapturePresenterImpl.java:425) at com.gun0912.tedpermission.TedInstance.onPermissionResult(TedInstance.java:67) at java.lang.reflect.Method.invoke(Method.java) at com.squareup.otto.EventHandler.handleEvent(EventHandler.java:89) at com.squareup.otto.Bus.dispatch(Bus.java:385) at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:368) at com.squareup.otto.Bus.post(Bus.java:337) at com.gun0912.tedpermission.busevent.TedBusProvider.post(TedBusProvider.java:49) at com.gun0912.tedpermission.TedPermissionActivity.permissionGranted(TedPermissionActivity.java:115) at com.gun0912.tedpermission.TedPermissionActivity.onRequestPermissionsResult(TedPermissionActivity.java:208) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7460) at android.app.Activity.dispatchActivityResult(Activity.java:7286) at android.app.ActivityThread.deliverResults(ActivityThread.java:4516) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4563) at android.app.ActivityThread.-wrap22(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1698) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6776) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

Could not dispatch event

TedPermission을 적용한 앱을 런칭중에 있습니다.
사용자 uuid 생성을 위해 READ_PHONE_STATE 퍼미션을 받는 중에 다음과 같은 Exception이 발생했습니다.
proguard는 사용하고있지 않습니다.

java.lang.RuntimeException: Could not dispatch event: class com.gun0912.tedpermission.busevent.TedPermissionEvent to handler [EventHandler public void com.gun0912.tedpermission.TedInstance.onPermissionResult(com.gun0912.tedpermission.busevent.TedPermissionEvent)]: getDeviceId: Neither user 10232 nor current process has android.permission.READ_PHONE_STATE. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3254) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) at android.app.ActivityThread.access$1100(ActivityThread.java:222) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7237) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Caused by java.lang.RuntimeException: Could not dispatch event: class com.gun0912.tedpermission.busevent.TedPermissionEvent to handler [EventHandler public void com.gun0912.tedpermission.TedInstance.onPermissionResult(com.gun0912.tedpermission.busevent.TedPermissionEvent)]: getDeviceId: Neither user 10232 nor current process has android.permission.READ_PHONE_STATE. at com.squareup.otto.Bus.throwRuntimeException(Bus.java:460) at com.squareup.otto.Bus.dispatch(Bus.java:387) at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:368) at com.squareup.otto.Bus.post(Bus.java:337) at com.gun0912.tedpermission.busevent.TedBusProvider.post(TedBusProvider.java:49) at com.gun0912.tedpermission.TedPermissionActivity.permissionGranted(TedPermissionActivity.java:115) at com.gun0912.tedpermission.TedPermissionActivity.onRequestPermissionsResult(TedPermissionActivity.java:208) at android.app.Activity.requestPermissions(Activity.java:4163) at android.support.v4.app.ActivityCompatApi23.requestPermissions(ActivityCompatApi23.java:45) at android.support.v4.app.ActivityCompat.requestPermissions(ActivityCompat.java:375) at com.gun0912.tedpermission.TedPermissionActivity.requestPermissions(TedPermissionActivity.java:184) at com.gun0912.tedpermission.TedPermissionActivity.checkPermissions(TedPermissionActivity.java:175) at com.gun0912.tedpermission.TedPermissionActivity.onCreate(TedPermissionActivity.java:58) at android.app.Activity.performCreate(Activity.java:6876) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3207) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3350) at android.app.ActivityThread.access$1100(ActivityThread.java:222) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7237) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

Open an activity after check permission is not available.

I'm trying to open an activity after permission check.
Here's how I code :

protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PermissionListener permissionlistener = new PermissionListener() {
        @Override
        public void onPermissionGranted() {
            Toast.makeText(RationaleDenyActivity.this, "Permission Granted", Toast.LENGTH_SHORT).show();
        }
        @Override
        public void onPermissionDenied(ArrayList<String> deniedPermissions) {
            Toast.makeText(RationaleDenyActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show();
        }


    };
   new TedPermission(this)
            .setPermissionListener(permissionlistener)
            .setRationaleMessage("we need permission for read contact and find your location")
            .setDeniedMessage("If you reject permission,you can not use this service\n\nPlease turn on permissions at [Setting] > [Permission]")
            .setGotoSettingButtonText("bla bla")
            .setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.ACCESS_FINE_LOCATION)
            .check();
    Intent intent=null;
    intent = new Intent(this,AfterCheckActivity.class);
    if(intent!=null){
        startActivity(intent);
    }
}

This will make the permission dialog show up after AfterCheckActivity finish.
If I want to open an activity after check permission, where should I put the TedPermission.check() ?

AppCompat Theme issue... #2

Sorry for belated response to this. I haven't had time to circle back to this until today. I've uploaded my sample to google drive ( https://drive.google.com/folderview?id=0B5qQYhAfSI7kUy1KekI3aVRsc0E&usp=sharing ) so you can pull it down and run it. I still get the error:

03-27 13:00:02.351 29449-29449/dataforensics.sample_mpermissions E/AndroidRuntime: FATAL EXCEPTION: main
Process: dataforensics.sample_mpermissions, PID: 29449
java.lang.RuntimeException: Unable to start activity ComponentInfo{dataforensics.sample_mpermissions/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:331)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.onPostCreate(AppCompatDelegateImplV7.java:164)
at android.support.v7.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:87)
at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1188)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2398)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

com.jfrog.bintray 오류가 발생됩니다.

수고 많으십니다
오류 로그 전문입니다.

Caused by: org.gradle.api.plugins.UnknownPluginException: Plugin with id 'com.jfrog.bintray' not found.
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:110)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:112)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:35)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:79)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:135)
at org.gradle.groovy.scripts.DefaultScript.apply(DefaultScript.java:109)
at org.gradle.api.Script$apply$0.callCurrent(Unknown Source)
at bintrayv1_76e1dnwmf4o7tzwnw7d93bcjx.run(https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle:1)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)

Activity is closed but dialog permission is showed

I call this fuction on created method, but Activity is closed but dialog permission is showed. Please fix it
`@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);

    new TedPermission(this)
            .setPermissionListener(permissionScanQrcodeListener)
            .setDeniedMessage("Permission dibutuhkan untuk Mode Offline.\nHidupkan permission WRITE_EXTERNAL_STORAGE pada [Setting] > [Permission]")
            .setPermissions(Manifest.permission.WRITE_EXTERNAL_STORAGE)
            .check();
}`

Rotational issue

Hi.
When the rotation is enabled and the dialog is showing, if I turn the device the method "onPermissionGranted" is called even if the user didn't make his decision.

AppCompat Theme issue...

I have a hello world activity that I dropped this lib in to try it out. I'm getting an issue for AppCompatTheme, see log here:

FATAL EXCEPTION: main
Process: sample.sample_mpermissions, PID: 7863
java.lang.RuntimeException: Unable to start activity ComponentInfo{sample.sample_mpermissions/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:331)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:300)
at android.support.v7.app.AppCompatDelegateImplV7.onPostCreate(AppCompatDelegateImplV7.java:164)
at android.support.v7.app.AppCompatActivity.onPostCreate(AppCompatActivity.java:87)
at android.app.Instrumentation.callActivityOnPostCreate(Instrumentation.java:1188)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2398)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I already have them in manifest (android:theme="@style/AppTheme") thats using my theme from my styles XML:

`

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>`

Thoughts on what to try?

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState

05-30 16:39:29.510 8994-8994/io..E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.., PID: 8994
java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=10, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {io../apptitude.io.aplibrary.runtimepermissions.TedPermissionActivity}: java.lang.RuntimeException: Could not dispatch event: class apptitude.io.aplibrary.runtimepermissions.busevent.TedPermissionEvent to handler [EventHandler public void apptitude.io.aplibrary.runtimepermissions.TedInstance.onPermissionResult(apptitude.io.aplibrary.runtimepermissions.busevent.TedPermissionEvent)]: Can not perform this action after onSaveInstanceState
at android.app.ActivityThread.deliverResults(ActivityThread.java:3699)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)
at android.app.ActivityThread.-wrap16(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.RuntimeException: Could not dispatch event: class apptitude.io.aplibrary.runtimepermissions.busevent.TedPermissionEvent to handler [EventHandler public void apptitude.io.aplibrary.runtimepermissions.TedInstance.onPermissionResult(apptitude.io.aplibrary.runtimepermissions.busevent.TedPermissionEvent)]: Can not perform this action after onSaveInstanceState
at com.squareup.otto.Bus.throwRuntimeException(Bus.java:460)
at com.squareup.otto.Bus.dispatch(Bus.java:387)
at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:368)
at com.squareup.otto.Bus.post(Bus.java:337)
at apptitude.io.aplibrary.runtimepermissions.busevent.TedBusProvider.post(TedBusProvider.java:49)
at apptitude.io.aplibrary.runtimepermissions.TedPermissionActivity.permissionGranted(TedPermissionActivity.java:100)
at apptitude.io.aplibrary.runtimepermissions.TedPermissionActivity.onRequestPermissionsResult(TedPermissionActivity.java:191)
at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6582)
at android.app.Activity.dispatchActivityResult(Activity.java:6460)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) 
at android.app.ActivityThread.-wrap16(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1493)
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1511)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:634)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:613)

데모앱에 대한 질문..

데모앱을 갤럭시S6(Android 7.0)에 설치해서 실행해보던중 궁금한 점? 남깁니다.
앱 권한 거부후 나타나는 알림창에서
'setting"버튼 클릭시
앱 권한 설정화면으로 넘어가는것이 아니라..
그냥
앱 정보화면으로 이동하는데 이게 맞는건가요?

"SETTING" always in English

Please add some like setDeniedSettingButtonText();
SETTING is always in English but my applications are in other languages.

NotFoundException

Please help me.
FYI - I've added produgard into apps.


java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=10, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS VirtualScreenParam=Params{mDisplayId=-1, null, mFlags=0x00000000)} (has extras) }} to activity {mdirectory.secapps.com.mdirectory/com.gun0912.tedpermission.TedPermissionActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0
	at android.app.ActivityThread.deliverResults(ActivityThread.java:5007)
	at android.app.ActivityThread.handleSendResult(ActivityThread.java:5050)
	at android.app.ActivityThread.access$1600(ActivityThread.java:230)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1876)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:7409)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
	at android.content.res.Resources.getValue(Resources.java:2598)
	at android.content.res.Resources.loadXmlResourceParser(Resources.java:4431)
	at android.content.res.Resources.getLayout(Resources.java:2412)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
	at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
	at android.support.v7.app.y.b(SourceFile:292)
	at android.support.v7.app.ah.setContentView(SourceFile:83)
	at android.support.v7.app.AlertController.a(SourceFile:225)
	at android.support.v7.app.n.onCreate(SourceFile:257)
	at android.app.Dialog.dispatchOnCreate(Dialog.java:733)
	at android.app.Dialog.show(Dialog.java:469)
	at android.support.v7.app.n$a.c(SourceFile:955)
	at com.gun0912.tedpermission.TedPermissionActivity.showPermissionDenyDialog(SourceFile:270)
	at com.gun0912.tedpermission.TedPermissionActivity.onRequestPermissionsResult(SourceFile:197)
	at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7291)
	at android.app.Activity.dispatchActivityResult(Activity.java:7169)
	at android.app.ActivityThread.deliverResults(ActivityThread.java:5003)
	... 9 more

Methods lose in v1.0.3

image
So many methods lost in v1.0.3, please add them, thanks!
version: compile 'com.github.ParkSangGwon:TedPermission:v1.0.3'

NullPointerException?

#1 main

java.lang.NullPointerException
Attempt to invoke interface method 'void com.gun0912.tedpermission.PermissionListener.onPermissionGranted()' on a null object reference
解析原始
}
1 java.lang.RuntimeException:Unable to start activity ComponentInfo{com.ks.kaishustory/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.RuntimeException: Could not dispatch event: class com.gun0912.tedpermission.busevent.TedPermissionEvent to handler [EventHandler public void com.gun0912.tedpermission.TedInstance.onPermissionResult(com.gun0912.tedpermission.busevent.TedPermissionEvent)]: Attempt to invoke interface method 'void com.gun0912.tedpermission.PermissionListener.onPermissionGranted()' on a null object reference
2 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2423)
3 ......
4 Caused by:
5 java.lang.NullPointerException:Attempt to invoke interface method 'void com.gun0912.tedpermission.PermissionListener.onPermissionGranted()' on a null object reference
6 com.gun0912.tedpermission.TedInstance.onPermissionResult(TedInstance.java:65)
7 java.lang.reflect.Method.invoke(Native Method)
8 com.squareup.otto.EventHandler.handleEvent(EventHandler.java:89)
9 com.squareup.otto.Bus.dispatch(Bus.java:385)
10 com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:368)
11 com.squareup.otto.Bus.post(Bus.java:337)
12 com.gun0912.tedpermission.busevent.TedBusProvider.post(TedBusProvider.java:49)
13 com.gun0912.tedpermission.TedPermissionActivity.permissionGranted(TedPermissionActivity.java:115)
14 com.gun0912.tedpermission.TedPermissionActivity.checkPermissions(TedPermissionActivity.java:159)
15 com.gun0912.tedpermission.TedPermissionActivity.onCreate(TedPermissionActivity.java:58)
16 android.app.Activity.performCreate(Activity.java:6303)
17 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
18 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
19 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
20 android.app.ActivityThread.access$900(ActivityThread.java:153)
21 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
22 android.os.Handler.dispatchMessage(Handler.java:102)
23 android.os.Looper.loop(Looper.java:148)
24 android.app.ActivityThread.main(ActivityThread.java:5442)
25 java.lang.reflect.Method.invoke(Native Method)
26 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
27 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

Error:Plugin with id 'com.jfrog.bintray' not found.

Your project downloaded from github can not be compiled in WIndows 10 under Android Studio 2.2.2 and Intellij IDEA 2016.2.5 due to gradle error

Error:Plugin with id 'com.jfrog.bintray' not found.

How to fix thi issue!?

appcompat error

version : 1.0.3

이슈 리스트에서 appcompat 관련 에러를 찾아보았습니다.

우선 저는 AppCompat 테마를 사용하고 있고 manifest에 application 의 theme 에 적용하고있습니다.

하지만 여전히 테드 퍼미션을 사용시
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
와 같은 에러가 발생합니다.

AndroidManifest.xml

 <application
        android:name="com.xiilab.servicedev.cheesecounter.ApplicationClass"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.NoActionBar">
...

style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="windowNoTitle">true</item>
        <item name="colorPrimary">@color/main_yellow</item>
        <item name="colorPrimaryDark">@color/main_yellow</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar" parent="AppTheme">
        <item name="windowActionBar">true</item>
        <item name="windowNoTitle">true</item>
    </style>

Memory leak warning in Android Studio.

If you load your code in AS this warning appears:

Do not place Android context classes in static fields (static reference to TedInstance which has field context pointing to Context); 
this is a memory leak (and also breaks Instant Run).  A static field will leak contexts.

ted_permission_memory_leak

Is there a way to avoid memory leaks using your library?

leakcanary : leaks DenyActivity instance

메모리 사용량 증가 때문에 leakcanary로 메모리 누수 체크를 하는데 "leaks DenyActivity instance"
메세지가 떠네요, 아직 초보라 모르는게 많아서 한번 체크 부탁 드립니다.

onPermissionResult Null!!! How?

Caused by java.lang.RuntimeException: Could not dispatch event: class com.gun0912.tedpermission.busevent.TedPermissionEvent to handler [EventHandler public void com.gun0912.tedpermission.TedInstance.onPermissionResult(com.gun0912.tedpermission.busevent.TedPermissionEvent)]: null

I have given all permissions and still it generating above exception on random times. Some times its working fine. Would you please help me in same context.

onCreate 에서 사용할 때...

안녕하세요...
마시멜로 에서 권한 문제 때문에 고민을 하다가... 구글링을 통해서 알게 되어 ... 잘 사용하고 있습니다.
감사드립니다.

궁금한 부분은

  1. onCreate 에서 권한이 필요한 부분이 아래 부분에 있는데... 잘 체크가 되지 않는 경우가 간혹 있는 것 같습니다.

  2. onCreate 에서 Service 을 실행시켰는데... 해당 서비스에서 권한이 필요한 경우 체크가 잘 될까요?

이런 경우가 있었는지 알려 주시면 도움이 될 것 같습니다. Thank You!!! 감사드려요...

난독화 실패

                                                 java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)' on a null object reference
                                                     at com.gun0912.tedpermission.util.Dlog.buildLogMsg(Unknown Source)
                                                     at com.gun0912.tedpermission.util.Dlog.d(Unknown Source)
                                                     at com.gun0912.tedpermission.TedPermission.check(Unknown 
Source)
                                                     at com.xxx.xxx.a.b(Unknown Source)
                                                   ~~~~
                                                     at android.os.Handler.handleCallback(Handler.java:739)
                                                     at android.os.Handler.dispatchMessage(Handler.java:95)
                                                     at android.os.Looper.loop(Looper.java:158)
                                                     at android.app.ActivityThread.main(ActivityThread.java:7237)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

해당 Dlog파일
https://github.com/ParkSangGwon/TedPermission/blob/master/tedpermission/src/main/java/com/gun0912/tedpermission/util/Dlog.java#L39
ste.getFileName()
가 Null이라서 오류가 발생하는 것 같습니다.

난독화 시에 파일이름이 없어져서(Unknown Source) 이러는것 갔습니다만...

위 로그에도 보시면 at com.xxx.xxx.a.b(Unknown Source)로 나오는데 이것과 같은 문제 인것 같네요.

오타있네요

우선 좋은 지식, 정보 공유 감사드립니다.

다름이 아니라 코드->셋업 부분 밑에

If you think this library is usuful, please press start button at upside.

이렇게 되어있는데

useful과 star가 맞는거 같아요 ㅎㅎ

An error in the flowchart

I think the flowchart explaining your library has a small error. Shouldn't the "SDK< 23" be directly forwarded to "Permission Granted"?. I think you should swap the places of SDK<23 and SDK>=23.

Thanks
Ajay

denniedmessage always show

When I show the dialog, I click accept button and denied message show. How I can fix this?

I have try version 1.0.3 and 1.0.12 but I have got the same result

Ability to unregister listener

Is there any "proper" mecanism offered by the API to unregister the listener (usefull when dealing with lifecycle).
Cheers

Not working when obfuscating

Have you tried your library with 'minify' enabled ?
It does not work : more precisely, the PermissionListener is never triggered.

The following proguard rule should fix it. Please update Readme accordingly :

TedPermission

-keep class com.gun0912.tedpermission.** {
public protected private *;
}

Cheers

Error gradle

I do not use your TedPermission

Error Message
Error:(25, 13) Failed to resolve: com.github.ParkSangGwon:TedPermission:v1.0.11
Show in File
Show in Project Structure dialog

my gradle
buildscript {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"

defaultConfig {
    applicationId "com.smd.myapplication"
    minSdkVersion 18
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.github.ParkSangGwon:TedPermission:v1.0.11'
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.