OnRequestPermissionsResultCallback接口如何工作?

时间:2017-04-15 15:40:41

标签: android interface permissions

如果在请求权限之后需要调用onRequestPermissionsResult,那么为什么android studio不会像其他接口一样强制你调用onRequestPermissionsResult?

感谢。

1 个答案:

答案 0 :(得分:1)

不会致电List<Attraction> attractions = new ArrayList<>(); ref.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for(DataSnapshot val : dataSnapshot.getChildren()){ Attraction attraction = val.getValue(Attraction.class); attraction.setName(val.getKey()); //This is because the key is the attraction name based on the structure attractions.add(attraction)); } //After getting all of them in a list, return them return attractions; //use this if you want to return them as a List Object return attractions.toArray(new Attraction[attractions.size()]); //use this if you want to return it as an array } @Override public void onCancelled(FirebaseError firebaseError) { } }) ,只需致电onRequestPermissionsResult()onCreate()。在您调用onSaveInstanceState()之后,框架调用onRequestPermissionsResult(),更重要的是,在用户处理了出现的权限对话框之后调用{<1}}。

除此之外:

  • requestPermissions()不是界面,也不是界面的成员

  • 没有IDE强制您调用接口上的方法,因为Java不会强制您调用接口上的方法