Don't know what I'm doing wrong. When trying to compile Android studio code I get the following error:
';' expected
Code Error Image error: type annotations are not supported in -source 1.7
@Override
public void onRequestPermissionsResult(int requestCode,
String[] permissions, int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_READ_CONTACTS: {
// 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.
}
}
Remove onRequestPermissionsResult()
method outside of onCreate()
method bracket.
Like below,
int MY_PERMISSIONS_REQUEST_READ_CONTACTS = 0;
@Override
protected void onCreate(Bundle savedInstantState){
....
....
}
@Override
public void onRequestPermissionsResult(int requestCode,
String[] permissions, int[] grantResults) {
....
....
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.