0

The Below is code for asking user permissions.If the user gives permissions then i have to take him to the next screen.After user allows permissions..then i have to take him to next screen

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        if (android.os.Build.VERSION.SDK_INT >= 23) {
            if(!hasPermissions(this, PERMISSIONS)){
                ActivityCompat.requestPermissions(this, PERMISSIONS, PERMISSION_ALL);
            }
        }else{
            Intent intent = new Intent(MainActivity.this,LoginActivity.class);
            startActivity(intent);
        }
    }

If I use the code below.

onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)

it is showing this error

"the method is not overriding anything with current build target,but will in api 23 current level 17"

SripadRaj
  • 1,687
  • 2
  • 22
  • 33
Teja
  • 837
  • 3
  • 14
  • 24
  • Change Your target SDK version to 23. – Janak Oct 18 '16 at 06:19
  • @Janak.....Target SDK is 23 only ..... – Teja Oct 18 '16 at 06:20
  • No, also set compileSdkVersion to 23 and change build version according to compile SDK Version. – Janak Oct 18 '16 at 06:23
  • What you have Extend with MainActivity? – anonymous Oct 18 '16 at 06:26
  • onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) this method override only with FragmentActivity or AppCompatActivity – anonymous Oct 18 '16 at 06:27
  • @anonymous... it is also work with Activity class. – Janak Oct 18 '16 at 06:30
  • ok............. @Janak – anonymous Oct 18 '16 at 06:33
  • @Janak......But It will affect previous versions.....This is very old application..I am using HTTP Client for this.If I change compilesdkversion to 23....The Old things are not recognised – Teja Oct 18 '16 at 06:37
  • @Teja... Write --> useLibrary('org.apache.http.legacy') in your Gradel above defaultConfig to use old HTTP Client. – Janak Oct 18 '16 at 06:44
  • Do i need to add that dependency.....It is showing..unable to find the library – Teja Oct 18 '16 at 06:58
  • @Teja.. check : http://stackoverflow.com/questions/30856785/how-to-add-apache-http-api-legacy-as-compile-time-dependency-to-build-grade-fo – Janak Oct 18 '16 at 07:03
  • @Teja... android official doc : https://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client – Janak Oct 18 '16 at 07:07
  • @Janak..IDK......I have tried all the solutions that i have got...It is showing the same error – Teja Oct 18 '16 at 07:27

0 Answers0