CopyPastor

Detecting plagiarism made easy.

Score: 0.8220768060187714; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2016-03-29
by Ashim Kansal

Original Post

Original - Posted on 2016-03-13
by Saveen



            
Present in both answers; Present only in the new answer; Present only in the old answer;

hi here is few steps for setup permission for android M and remember you should declare same permission in manifest file as well.
Step 1. Declare global variable :
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 0;
Step 2. Use this code in your main activity
private void locationpermission() { // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(activity , Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_COARSE_LOCATION)) {
// 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.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, MY_PERMISSIONS_REQUEST_LOCATION);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } }
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_LOCATION: { // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, yay! Do the // contacts-related task you need to do.
} else {
// permission denied, boo! Disable the // functionality that depends on this permission. } return; }
// other 'case' lines to check for other // permissions this app might request } }
Step 3. Call this method in your oncreate method,
locationpermission(); And anyone permission you can call from here and every result you can get in override method onRequestPermissionsResult this one.
thankyou
hope this will help you (Y).
please refer from here example
https://www.dropbox.com/s/w29sljy0zpwwm61/MyApplication.zip?dl=0
hi here is few steps for setup permission for android M and remember you should declare same permission in manifest file as well.
Step 1. Declare global variable :
public static final int MY_PERMISSIONS_REQUEST_LOCATION = 0;
Step 2. Use this code in your main activity
private void locationpermission() { // Here, thisActivity is the current activity if (ContextCompat.checkSelfPermission(activity , Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.ACCESS_COARSE_LOCATION)) {
// 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.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, MY_PERMISSIONS_REQUEST_LOCATION);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } }
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_LOCATION: { // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, yay! Do the // contacts-related task you need to do.
} else {
// permission denied, boo! Disable the // functionality that depends on this permission. } return; }
// other 'case' lines to check for other // permissions this app might request } }

Step 3. Call this method in your oncreate method,
locationpermission();

And anyone permission you can call from here and every result you can get in override method **onRequestPermissionsResult** this one.
thankyou
hope this will help you (Y).

        
Present in both answers; Present only in the new answer; Present only in the old answer;