0

I'm studying Android programming and I'm having an error. It says:

"com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission"

Code

https://pastebin.com/kZivbfCm

Permissions

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Error

Caused by: com.google.android.gms.auth.UserRecoverableAuthException: NeedPermission

I googled for whole day but not solved yet.

I'm using Youtube API and I have error for it.

Please help me.

Yes, added to Google API page.
https://i.sstatic.net/16PnR.png
And also YouTube API has ENABLED.

++ADDED

Class

    private Context context1;

    public YouTubePlaylistsLoader(Context context) {
        super(context);
        this.context1 = context;
    }

and I tried

 context1.startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);

But It says cannot resolve that function. I pressed Ctrl + SPACE and It only shows "startActivity(intent)"

3
  • Please include your code and the full text of the error. Commented Aug 8, 2017 at 7:01
  • Did you add api in developer console? Commented Aug 8, 2017 at 7:01
  • I added and finger print added Commented Aug 8, 2017 at 7:04

1 Answer 1

1

From your code where

        // I catched but I don't know how to handle.
        // I tried startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION); this but it gives me red line.
        // It says "Cannot resolve method startActivityForResult"
        // And also "Cannot resolve symbol REQUEST_AUTHORIZATION"

You need activity context to start activity for result. context.startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION); Take a look in here

Sign up to request clarification or add additional context in comments.

5 Comments

I tried but It says "Cannot resolve symbol 'context' ". Do I have to declare new one?
You have to add Context contex to the class constructor
I added on my post. Check please. thanks for answer. help me
use like that ((Activity)context)startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
Oh.. This worked perfectly. I love you so much. You're my savior. Thank you so much!!!!!!!!!!!!!! voted and checked. Thank you!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.