Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Added permission support for Android 6.0+ #17

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion app/src/main/java/com/google/ytdl/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.text.style.MetricAffectingSpan;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
Expand All @@ -41,7 +46,7 @@
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import android.Manifest;
import com.android.volley.toolbox.ImageLoader;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.api.client.extensions.android.http.AndroidHttp;
Expand Down Expand Up @@ -105,9 +110,16 @@ public class MainActivity extends Activity implements

@Override
protected void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT > 22) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {// if you want to check if permission has been given from before
final String[] permissions = new String[]{Manifest.permission.GET_ACCOUNTS};
ActivityCompat.requestPermissions(this, permissions, 0);
}
}
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);


mUploadsListFragment = new UploadsListFragment(getApplicationContext());

// Check to see if the proper keys and playlist IDs have been set up
Expand Down Expand Up @@ -645,4 +657,17 @@ public void onReceive(Context context, Intent intent) {
}
}
}

/* @Override

public void onRequestPermissionsResult(int permsRequestCode, String[] permissions, int[] grantResults) { // here for reference , can be commented out if required

switch (permsRequestCode) {

case 200:
boolean audioAccepted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
break;

}
}*/
}