Created
December 13, 2016 06:09
-
-
Save lhjnano/0fc199eae45150fe88b30a69214aec70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gluesys.nvr; | |
import android.Manifest; | |
import android.content.pm.PackageManager; | |
import android.os.Environment; | |
import android.support.v4.app.ActivityCompat; | |
import android.support.v4.content.ContextCompat; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import com.gluesys.util.NDKAdapter; | |
import java.io.File; | |
public class MainActivity extends AppCompatActivity { | |
final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE =0; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
if (ContextCompat.checkSelfPermission(this,Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED) { | |
// 이 권한을 필요한 이유를 설명 | |
// It can see the file list in external storage. | |
if (ActivityCompat.shouldShowRequestPermissionRationale(this,Manifest.permission.WRITE_EXTERNAL_STORAGE)) { | |
// 다이어로그같은것을 띄워서 사용자에게 해당 권한이 필요한 이유에 대해 설명합니다 | |
// 해당 설명이 끝난뒤 requestPermissions()함수를 호출하여 권한허가를 요청해야 합니다 | |
} else { | |
ActivityCompat.requestPermissions(this, | |
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, | |
MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); | |
// 필요한 권한과 요청 코드를 넣어서 권한허가요청에 대한 결과를 받아야 합니다 | |
} | |
} | |
else { | |
new NDKAdapter().run_ffmpeg(); | |
} | |
} | |
@Override | |
public void onRequestPermissionsResult(int requestCode, | |
String permissions[], int[] grantResults) { | |
switch (requestCode) { | |
case MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: | |
if (grantResults.length > 0 | |
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
// 권한 허가 | |
// 해당 권한을 사용해서 작업을 진행할 수 있습니다 | |
new NDKAdapter().run_ffmpeg(); | |
} else { | |
// 권한 거부 | |
// 사용자가 해당권한을 거부했을때 해주어야 할 동작을 수행합니다 | |
} | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment