| | |
| | | import android.os.Bundle; |
| | | import android.os.Process; |
| | | import android.provider.Settings; |
| | | import android.support.annotation.NonNull; |
| | | import android.support.v4.app.ActivityCompat; |
| | | import android.support.v4.content.ContextCompat; |
| | | import android.support.v4.content.PermissionChecker; |
| | | import android.util.Log; |
| | | import android.view.View; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.RelativeLayout; |
| | | import android.view.KeyEvent; |
| | | |
| | | import com.unity3d.player.UnityPlayerActivity; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class MainActivity extends UnityPlayerActivity |
| | | { |
| | |
| | | |
| | | super.onResume(); |
| | | |
| | | // 检测本地存储权限是否有, 没有的话要提示用户 |
| | | if (PermissionChecker.checkPermission(this, |
| | | Manifest.permission.WRITE_EXTERNAL_STORAGE, |
| | | Process.myPid(), Process.myUid(), |
| | | getPackageName()) != PackageManager.PERMISSION_GRANTED |
| | | || PermissionChecker.checkPermission(this, |
| | | Manifest.permission.READ_EXTERNAL_STORAGE, |
| | | Process.myPid(), Process.myUid(), |
| | | getPackageName()) != PackageManager.PERMISSION_GRANTED) |
| | | { |
| | | new AlertDialog.Builder(this) |
| | | .setMessage("应用没有存储读取权限,点击确定至设置中开启,否则无法继续游戏.") |
| | | .setCancelable(false) |
| | | .setPositiveButton("确定", |
| | | new DialogInterface.OnClickListener() |
| | | { |
| | | @Override |
| | | public void onClick(DialogInterface dialogInterface, |
| | | int i) |
| | | { |
| | | UniversalUtil.hasGoToSetting = true; |
| | | Intent intent = new Intent( |
| | | Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | Uri uri = Uri.fromParts("package", |
| | | getPackageName(), |
| | | null); |
| | | intent.setData(uri); |
| | | startActivity(intent); |
| | | } |
| | | }) |
| | | .setNegativeButton("拒绝", |
| | | new DialogInterface.OnClickListener() |
| | | { |
| | | @Override |
| | | public void onClick(DialogInterface dialogInterface, |
| | | int i) |
| | | { |
| | | finish(); |
| | | } |
| | | }) |
| | | .show(); |
| | | } |
| | | // // 检测本地存储权限是否有, 没有的话要提示用户 |
| | | // if (PermissionChecker.checkPermission(this, |
| | | // Manifest.permission.WRITE_EXTERNAL_STORAGE, |
| | | // Process.myPid(), Process.myUid(), |
| | | // getPackageName()) != PackageManager.PERMISSION_GRANTED |
| | | // || PermissionChecker.checkPermission(this, |
| | | // Manifest.permission.READ_EXTERNAL_STORAGE, |
| | | // Process.myPid(), Process.myUid(), |
| | | // getPackageName()) != PackageManager.PERMISSION_GRANTED) |
| | | // { |
| | | // new AlertDialog.Builder(this) |
| | | // .setMessage("应用没有存储读取权限,点击确定至设置中开启,否则无法继续游戏.") |
| | | // .setCancelable(false) |
| | | // .setPositiveButton("确定", |
| | | // new DialogInterface.OnClickListener() |
| | | // { |
| | | // @Override |
| | | // public void onClick(DialogInterface dialogInterface, |
| | | // int i) |
| | | // { |
| | | // UniversalUtil.hasGoToSetting = true; |
| | | // Intent intent = new Intent( |
| | | // Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| | | // Uri uri = Uri.fromParts("package", |
| | | // getPackageName(), |
| | | // null); |
| | | // intent.setData(uri); |
| | | // startActivity(intent); |
| | | // } |
| | | // }) |
| | | // .setNegativeButton("拒绝", |
| | | // new DialogInterface.OnClickListener() |
| | | // { |
| | | // @Override |
| | | // public void onClick(DialogInterface dialogInterface, |
| | | // int i) |
| | | // { |
| | | // finish(); |
| | | // } |
| | | // }) |
| | | // .show(); |
| | | // } |
| | | } |
| | | |
| | | @Override |
| | |
| | | super.onRestart(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean onKeyDown(int i, KeyEvent keyEvent) |
| | | { |
| | | if (i == KeyEvent.KEYCODE_BACK) |
| | | { |
| | | KYPlatformUtil.getInstance().logout(); |
| | | } |
| | | return false; |
| | | } |
| | | } |