Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
public class CallActivity extends AppCompatActivity {
@Override
public void onClick(View view) {
if (ContextCompat.checkSe...
public class CallActivity extends AppCompatActivity {
@Override
public void onClick(View view) {
if (ContextCompat.checkSe...
public class CallActivity extends AppCompatActivity {
@Override
public void onClick(View view) {
if (ContextCompat.checkSe...
public class CallActivity extends AppCompatActivity {
@Override
public void onClick(View view) {
if (ContextCompat.checkSe...
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults)
{
switch (requ...
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults)
{
switch (requ...
public class CallActivity extends AppCompatActivity {
@NeedPermission(
permissions ={Manifest.permission.READ_CONTACTS}
de...
public class CallActivity extends AppCompatActivity {
@NeedPermission(
permissions ={Manifest.permission.READ_CONTACTS}
de...
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.hu...
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.hu...
apply plugin: 'com.android.application'
apply plugin: 'android-aspectjx'
android {
compileSdkVersion 23
defaultConfig {
ta...
apply plugin: 'com.android.application'
apply plugin: 'android-aspectjx'
android {
compileSdkVersion 23
defaultConfig {
ta...
public class AspectApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
PermissionCheckS...
public class AspectApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
PermissionCheckS...
@NeedPermission(
permissions ={Manifest.permission.READ_CONTACTS}
deniedMessage=“ !”)
public void Hoge() {
}
•RuntimePermisson AOP
•PermissionAspect
•
•
• AOP
RuntimePermissionをAOPで解決してみた話
RuntimePermissionをAOPで解決してみた話
RuntimePermissionをAOPで解決してみた話
RuntimePermissionをAOPで解決してみた話
RuntimePermissionをAOPで解決してみた話
RuntimePermissionをAOPで解決してみた話
Upcoming SlideShare
Loading in …5
×

RuntimePermissionをAOPで解決してみた話

1,136 views

Published on

2016/08/23(火) 19:00〜
potatotips #32 (iOS/Android開発Tips共有会)

Published in: Mobile
  • Be the first to comment

  • Be the first to like this

RuntimePermissionをAOPで解決してみた話

  1. 1. public class CallActivity extends AppCompatActivity { @Override public void onClick(View view) { if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { // ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_CONTACTS}, MY_PERMISSIONS_REQUEST_READ_CONTACTS); return; } // Hoge(); } } public void Hoge(View view) { // }
  2. 2. public class CallActivity extends AppCompatActivity { @Override public void onClick(View view) { if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { // ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_CONTACTS}, MY_PERMISSIONS_REQUEST_READ_CONTACTS); return; } // Hoge(); } } public void Hoge(View view) { // }
  3. 3. public class CallActivity extends AppCompatActivity { @Override public void onClick(View view) { if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { // ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_CONTACTS}, MY_PERMISSIONS_REQUEST_READ_CONTACTS); return; } // Hoge(); } } public void Hoge(View view) { // }
  4. 4. public class CallActivity extends AppCompatActivity { @Override public void onClick(View view) { if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { // ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_CONTACTS}, MY_PERMISSIONS_REQUEST_READ_CONTACTS); return; } // Hoge(); } } public void Hoge(View view) { // }
  5. 5. @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_READ_CONTACTS: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Hoge(); } else { Toast.makeText(this, “ !”, Toast.LENGTH_LONG).show(); } return; } } }
  6. 6. @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case MY_PERMISSIONS_REQUEST_READ_CONTACTS: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Hoge(); } else { Toast.makeText(this, “ !”, Toast.LENGTH_LONG).show(); } return; } } }
  7. 7. public class CallActivity extends AppCompatActivity { @NeedPermission( permissions ={Manifest.permission.READ_CONTACTS} deniedMessage=“ !”) public void Hoge() { } }
  8. 8. public class CallActivity extends AppCompatActivity { @NeedPermission( permissions ={Manifest.permission.READ_CONTACTS} deniedMessage=“ !”) public void Hoge() { } }
  9. 9. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.5' } }
  10. 10. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.2' classpath 'com.hujiang.aspectjx:gradle-android-plugin-aspectjx:1.0.5' } }
  11. 11. apply plugin: 'com.android.application' apply plugin: 'android-aspectjx' android { compileSdkVersion 23 defaultConfig { targetSdkVersion 23 } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.firefly1126.permissionaspect:permissionaspect:1.0.0' }
  12. 12. apply plugin: 'com.android.application' apply plugin: 'android-aspectjx' android { compileSdkVersion 23 defaultConfig { targetSdkVersion 23 } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.firefly1126.permissionaspect:permissionaspect:1.0.0' }
  13. 13. public class AspectApplication extends Application { @Override public void onCreate() { super.onCreate(); PermissionCheckSDK.init(this); } }
  14. 14. public class AspectApplication extends Application { @Override public void onCreate() { super.onCreate(); PermissionCheckSDK.init(this); } }
  15. 15. @NeedPermission( permissions ={Manifest.permission.READ_CONTACTS} deniedMessage=“ !”) public void Hoge() { }
  16. 16. •RuntimePermisson AOP •PermissionAspect • • • AOP

×