|
|
@@ -4,6 +4,7 @@ import android.content.Intent;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
+import android.support.v7.app.AlertDialog;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.view.WindowManager;
|
|
|
|
|
|
@@ -34,7 +35,7 @@ public class MainActivity extends BaseActivity implements BackHandlerInterface {
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
|
|
|
-
|
|
|
+ initPermissions();
|
|
|
Intent intent = getIntent();
|
|
|
if (intent != null) {
|
|
|
isConnected = intent.getBooleanExtra("isConnected", false);
|
|
|
@@ -84,6 +85,35 @@ public class MainActivity extends BaseActivity implements BackHandlerInterface {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void initPermissions() {
|
|
|
+ AndPermission.with(this)
|
|
|
+ .runtime()
|
|
|
+ .permission(
|
|
|
+ Permission.Group.STORAGE,
|
|
|
+ Permission.Group.CAMERA
|
|
|
+ )
|
|
|
+ .rationale(new Rationale<List<String>>() {
|
|
|
+ @Override
|
|
|
+ public void showRationale(Context context, List<String> data, RequestExecutor executor) {
|
|
|
+ new AlertDialog.Builder(MainActivity.this)
|
|
|
+ .setTitle("提示")
|
|
|
+ .setMessage("APP运行需要部分权限,请确认授权")
|
|
|
+ .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ executor.cancel();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ executor.execute();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .show();
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
protected void onDestroy() {
|