| | |
| | | import android.content.pm.ActivityInfo; |
| | | import android.content.pm.PackageManager; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.ColorMatrix; |
| | | import android.graphics.ColorMatrixColorFilter; |
| | | import android.graphics.Paint; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.net.Uri; |
| | | import android.os.AsyncTask; |
| | | import android.os.Build; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.support.v4.app.ActivityCompat; |
| | | import android.support.v4.content.ContextCompat; |
| | | import android.telephony.TelephonyManager; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.core.app.ActivityCompat; |
| | | import androidx.core.content.ContextCompat; |
| | | import androidx.fragment.app.FragmentActivity; |
| | | |
| | | import android.view.KeyEvent; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.ImageView; |
| | | import android.widget.TextView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.google.gson.Gson; |
| | | import com.lcjian.library.dialog.DialogUtil; |
| | | import com.lcjian.library.util.ManifestDataUtil; |
| | | import com.lcjian.library.util.ScreenUtils; |
| | | import com.lcjian.library.util.common.BitmapUtils; |
| | | import com.lcjian.library.util.common.DrawableUtils; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.lcjian.library.util.glide.GlideRoundTransform; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | | import com.weikou.beibeivideo.BeibeiVideoApplication; |
| | |
| | | import com.weikou.beibeivideo.entity.ad.AdPidInfo; |
| | | import com.weikou.beibeivideo.entity.ad.AdPositionEnum; |
| | | import com.weikou.beibeivideo.entity.ad.AdTypeVO; |
| | | import com.weikou.beibeivideo.entity.ad.SplashAdLoadInfo; |
| | | import com.weikou.beibeivideo.ui.ad.SplashADFragment; |
| | | import com.weikou.beibeivideo.ui.dialog.PermissionAuthNotifyDialog; |
| | | import com.weikou.beibeivideo.ui.dialog.UserProtocolDialog; |
| | | import com.weikou.beibeivideo.ui.main.MainActivity; |
| | | import com.weikou.beibeivideo.util.BeibeiConstant; |
| | |
| | | import com.weikou.beibeivideo.util.ad.AdUtil; |
| | | import com.weikou.beibeivideo.util.ad.CSJConstant; |
| | | import com.weikou.beibeivideo.util.ad.GDTConstant; |
| | | import com.weikou.beibeivideo.util.ad.SplashAdUtil; |
| | | import com.weikou.beibeivideo.util.ad.KSConstant; |
| | | import com.weikou.beibeivideo.util.ad.manager.gm.GMAdSplashManager; |
| | | import com.weikou.beibeivideo.util.ui.AiDaoUtil; |
| | | import com.weikou.beibeivideo.util.ui.TopStatusSettings; |
| | | |
| | | import org.apache.http.Header; |
| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import static android.content.pm.PackageManager.PERMISSION_DENIED; |
| | | import static android.content.pm.PackageManager.PERMISSION_GRANTED; |
| | | |
| | | public class SplashActivity extends BaseActivity { |
| | | public class SplashActivity extends FragmentActivity { |
| | | |
| | | boolean isInput = false; |
| | | |
| | |
| | | private ImageView iv_bg; |
| | | |
| | | private TextView ad_close_time; |
| | | private Dialog pdialog; |
| | | |
| | | private static String TAG = "SplashActivity"; |
| | | |
| | |
| | | }; |
| | | private static final int REQUEST_CODE = 0; // 请求码 |
| | | private PermissionsChecker mPermissionsChecker; // 权限检测器 |
| | | |
| | | private GMAdSplashManager mGMAdSplashManager; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | setContentView(R.layout.activity_splash); |
| | | TopStatusSettings.setStatusViewAndDeepColor(this); |
| | | |
| | | if (ConfigUtil.isAiDaoMode(this)) { |
| | | AiDaoUtil.setAiDaoMode(this); |
| | | } |
| | | |
| | | vg_ad = findViewById(R.id.fl_splash_ad); |
| | | vg_input = findViewById(R.id.fl_input); |
| | | ad_close_time = findViewById(R.id.ad_close_time); |
| | | iv_bg = findViewById(R.id.iv_bg); |
| | | |
| | | SharedPreferences preferences = getSharedPreferences("link_page", |
| | | Context.MODE_PRIVATE); |
| | | isInput = preferences.getBoolean("isInput", false); |
| | | try { |
| | | TelephonyManager manager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); |
| | | Build bd = new Build(); |
| | | String model = bd.MODEL; |
| | | BeibeiVideoApplication.deviceName = model; |
| | | BeibeiVideoApplication.deviceNumber = manager.getDeviceId(); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | mPermissionsChecker = new PermissionsChecker(this); |
| | | // 初始化大设备 |
| | | SDCardUtil.initStorage(this); |
| | | //初始化一次Banner,否则后面Banner使用时会出现卡顿 |
| | | // new BannerView(SplashActivity.this, ADSize.BANNER, BeibeiConstant.GDT_ID, BeibeiConstant.GDT_PLAYER_DETAIL); |
| | | //弹用户协议框 |
| | | |
| | | showProtocol(); |
| | | |
| | | |
| | | //设置背景图片 |
| | | Drawable drawable = getResources().getDrawable(R.drawable.ic_splash_bg); |
| | | Bitmap bitmap = DrawableUtils.drawableToBitmap(drawable); |
| | |
| | | iv_bg.setImageBitmap(bitmap1); |
| | | } |
| | | |
| | | private void init() { |
| | | SharedPreferences preferences = getSharedPreferences("link_page", |
| | | Context.MODE_PRIVATE); |
| | | isInput = preferences.getBoolean("isInput", false); |
| | | |
| | | mPermissionsChecker = new PermissionsChecker(this); |
| | | // 初始化大设备 |
| | | SDCardUtil.initStorage(this); |
| | | myRequetPermission(); |
| | | } |
| | | |
| | | private void showProtocol() { |
| | | String data = "感谢您对" + getResources().getString(R.string.app_name) + "一直以来的信任!<br>"; |
| | | data += "我们依照新的监管要求条例更新了"; |
| | | String data = "尊敬的用户:<br>感谢您对" + getResources().getString(R.string.app_name) + "一直以来的信任!<br>"; |
| | | data += "我们非常尊重并保护您的个人信息、隐私。为了更好的保障您的权利,在您使用我们的产品之前,请您务必审慎阅读"; |
| | | data += String.format("<a href='%s'>《隐私政策》</a>和", BeibeiConstant.PRIVACY_POLICY); |
| | | data += String.format("<a href='%s'>《用户协议》</a>", BeibeiConstant.USER_AGREEMENT); |
| | | data += "为采取相应安全保护措施,尽力保护您的个人信息安全可控,特向你说明如下:<br>" + |
| | | "1、您在使用" + getResources().getString(R.string.app_name) + "各项产品或服务时,将会提供与具体功能相关的个人信息(可能涉及帐号、位置、存储等信息)。<br>" + |
| | | "2、您可以随时查询、更正、删除您的个人信息,我们也提供账户注销的渠道。<br>" + |
| | | "3、未经您的再次同意,我们不会将上述信息用于您未授权的其他用途或目的。<br>" + |
| | | "4、未经监护人同意,我们不会收集使用14周岁以下(含14周岁)未成年人个人信息,且不会利用其信息推送新闻、时政信息、广告等定向推送活动。"; |
| | | data += "内的所有条款,<b>尤其是:<br>" + |
| | | "1、)为识别您的设备,并预防恶意程序及反作弊、提高服务安全性、保障运营质量及效率,我们会收集您" + |
| | | "的设备信息(包括<font color='#FF0000'>IMEI、设备序列号、OAID、MEID、Android ID、IMSI、GUID、MAC地址、SIM卡序列号</font> )、<font color='#FF0000'>已安装APP信息</font>或运行中的进程信息<br>" + |
| | | "2、约定我们的限制责任、免责条款;<br>" + |
| | | "3、其他以加粗或斜体字进行标识的重要条款。</b><br>" + |
| | | "如您对协议有任何疑虑,可通过电子邮箱: yesbd@qq.com 向我们询问,我们将为您竭诚解答。您点击“同意并继续”的行为代表您已阅读完毕并接受以上协议全部条款。如您同意以上协议内容,请您点击“同意并继续”,开始使用您的产品。"; |
| | | |
| | | if (!UserUtil.isAgreeUserProtocol(BeibeiVideoApplication.application) && !BeibeiConstant.IS_TEST) { |
| | | Dialog dialog = new UserProtocolDialog.Builder(this).setNegativeButton("不同意", new DialogInterface.OnClickListener() { |
| | | pdialog = new UserProtocolDialog.Builder(this).setNegativeButton("不同意", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | SplashActivity.this.finish(); |
| | | DialogUtil.dismiss(pdialog); |
| | | AlertDialog alertDialog = new AlertDialog.Builder(SplashActivity.this).setTitle("温馨提示").setMessage("我们非常重视对您个人信息的保护,承诺严格按照"+ getResources().getString(R.string.app_name) +"隐私权政策保护及处理您的信息,如不同意该政策,很遗憾我们将无法提供服务").setNegativeButton("退出应用", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | SplashActivity.this.finish(); |
| | | } |
| | | }).setPositiveButton("再次查看", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog_, int which) { |
| | | DialogUtil.show(pdialog); |
| | | } |
| | | }).create(); |
| | | alertDialog.setCanceledOnTouchOutside(false); |
| | | alertDialog.show(); |
| | | } |
| | | }).setPositiveButton("同意并继续", new DialogInterface.OnClickListener() { |
| | | @Override |
| | |
| | | vg_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | myRequetPermission(); |
| | | |
| | | // new PermissionAuthNotifyDialog.Builder(SplashActivity.this).setPositiveButton(null, new DialogInterface.OnClickListener() { |
| | | // @Override |
| | | // public void onClick(DialogInterface dialogInterface, int i) { |
| | | // dialogInterface.dismiss(); |
| | | // init(); |
| | | // } |
| | | // }).create().show(); |
| | | init(); |
| | | } |
| | | }); |
| | | } |
| | | }).setData(data).create(); |
| | | |
| | | if (!isFinishing()) { |
| | | dialog.show(); |
| | | DialogUtil.show(pdialog); |
| | | } |
| | | |
| | | } else { |
| | |
| | | vg_ad.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | myRequetPermission(); |
| | | init(); |
| | | } |
| | | }); |
| | | } |
| | |
| | | |
| | | |
| | | BeibeiVideoAPI.getUid(this, channel, BeibeiVideoAPI.getDeviceId(this), preferences.getString("imei", ""), |
| | | preferences.getString("mac", ""), "", "", |
| | | "", "", |
| | | new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | |
| | | GDTConstant.PID_2_VIDEO_LIST_SMALL_AD_COLUMN2 = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_HOME_RECOMMEND_BIG_IMG = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_2_VIDEO_DETAIL_PLAYER_PRE_PPTV = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | GDTConstant.PID_2_EXIT = BeibeiConstant.GDT_DOWNLOAD_HINT_ID; |
| | | |
| | | CSJConstant.RECOMMEND_BIG_IMG_AD = CSJConstant.INVALID_AD; |
| | | CSJConstant.PPTV_INTERSTITIALAD = CSJConstant.INVALID_AD; |
| | | } |
| | | |
| | | //获取广告 |
| | |
| | | super.onPause(); |
| | | } |
| | | |
| | | |
| | | private String getDay(long time) { |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String date = format.format(new Date(time)); |
| | |
| | | @Override |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | if (mGMAdSplashManager != null) { |
| | | // mGMAdSplashManager.destroy(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | private SplashADFragment splashADFragment; |
| | | |
| | | private void loadSplashAd(AdUtil.AD_TYPE adType, String pid) { |
| | | |
| | | AdPidInfo adPidInfo2 = null; |
| | | if (adType == AdUtil.AD_TYPE.gdt) { |
| | | adPidInfo2 = new AdPidInfo(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | |
| | | } |
| | | |
| | | private void myRequetPermission() { |
| | | if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PERMISSION_GRANTED) { |
| | | ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_CODE); |
| | | } else { |
| | | //百度内容联盟 |
| | | // final String channel = ManifestDataUtil.getAppMetaData(getApplicationContext(), "UMENG_CHANNEL"); |
| | | // // 小米不弹出权限申请框 |
| | | // if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PERMISSION_GRANTED && !"xiaomi".equalsIgnoreCase(channel)) { |
| | | // SharedPreferences sharedPreferences = getSharedPreferences("permission", Context.MODE_PRIVATE); |
| | | // //是否需要再次请求权限 |
| | | // if (sharedPreferences.getBoolean("show", true)) { |
| | | // if ("huawei".equalsIgnoreCase(channel)) { |
| | | // next(); |
| | | // } else { |
| | | // ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_CODE); |
| | | // iv_bg.post(new Runnable() { |
| | | // @Override |
| | | // public void run() { |
| | | // findViewById(R.id.ll_authority_notify).setVisibility(View.VISIBLE); |
| | | // } |
| | | // }); |
| | | // } |
| | | // } else { |
| | | // next(); |
| | | // } |
| | | // } else { |
| | | // next(); |
| | | // } |
| | | next(); |
| | | } |
| | | |
| | | private void next() { |
| | | //百度内容联盟 |
| | | // MobadsPermissionSettings.setPermissionReadDeviceID(true); |
| | | getUid(); |
| | | vg_ad.postDelayed(new Runnable() { |
| | | iv_bg.post(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | findViewById(R.id.ll_authority_notify).setVisibility(View.GONE); |
| | | } |
| | | }); |
| | | |
| | | if (!BeibeiVideoApplication.IsInited()) { |
| | | BeibeiVideoApplication.init(BeibeiVideoApplication.application, new BeibeiVideoApplication.InitListener() { |
| | | @Override |
| | | public void run() { |
| | | if (!BeibeiConstant.AD_SETTING_KAIPIN) |
| | | toMainActivity(); |
| | | BeibeiVideoAPI.getConfig(getApplicationContext(), new BasicTextHttpResponseHandler() { |
| | | |
| | | public void onFinish() { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject != null) { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | JSONObject data = jsonObject.getJSONObject("Data"); |
| | | JSONObject ad = data.optJSONObject("adNew"); |
| | | String vipLink = data.optString("vipLink"); |
| | | int pptvNoAdRewardHour = data.optInt("pptvNoAdRewardHour", 3); |
| | | |
| | | //网页加速域名 |
| | | String webSpeedUpHost = data.optString("webSpeedUpHost"); |
| | | ConfigUtil.saveWebSpeedUpHost(getApplicationContext(), webSpeedUpHost); |
| | | //设置我的页面banner |
| | | ConfigUtil.saveMinePageBanner(getApplicationContext(), data.optString("minePageBanner")); |
| | | |
| | | ConfigUtil.savePlayerJumpOutProtocolPrefix(getApplicationContext(), data.optString("jumpAppProtocolPrefix")); |
| | | |
| | | //保存免广告权益持续时间 |
| | | AdUtil.setPPTVNoAdRewardHour(getApplicationContext(), pptvNoAdRewardHour); |
| | | |
| | | AdUtil.saveAdConfig(getApplicationContext(), ad); |
| | | AdUtil.AD_TYPE splash = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splash); |
| | | String pid = AdUtil.getAdPid(getApplicationContext(), AdPositionEnum.splash); |
| | | if (StringUtils.isBlank(pid)) { |
| | | if (splash != null) { |
| | | if (splash == AdUtil.AD_TYPE.csj) { |
| | | pid = CSJConstant.SPLASH_AD; |
| | | } else if (splash == AdUtil.AD_TYPE.gdt) { |
| | | pid = BeibeiConstant.GDT_SPLASH_POSITION_ID; |
| | | } |
| | | } |
| | | } |
| | | ConfigUtil.saveVipLink(getApplicationContext(), vipLink); |
| | | loadSplashAd(splash, pid); |
| | | } |
| | | } else { |
| | | loadSplashAd(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccess(int statusCode, Header[] headers, String responseString) { |
| | | super.onSuccess(statusCode, headers, responseString); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | loadSplashAd(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | | public void run() { |
| | | nextStep(); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }, 1000); |
| | | } |
| | | }); |
| | | } else |
| | | nextStep(); |
| | | } |
| | | |
| | | private void nextStep() { |
| | | |
| | | getUid(); |
| | | vg_ad.postDelayed(new Runnable() { |
| | | |
| | | @Override |
| | | public void run() { |
| | | if (!BeibeiConstant.AD_SETTING_KAIPIN) |
| | | toMainActivity(); |
| | | BeibeiVideoAPI.getConfig(getApplicationContext(), new BasicTextHttpResponseHandler() { |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject != null) { |
| | | if (jsonObject.getBoolean("IsPost")) { |
| | | JSONObject data = jsonObject.getJSONObject("Data"); |
| | | JSONObject ad = data.optJSONObject("adNew"); |
| | | String vipLink = data.optString("vipLink"); |
| | | int pptvNoAdRewardHour = data.optInt("pptvNoAdRewardHour", 3); |
| | | |
| | | //网页加速域名 |
| | | String webSpeedUpHost = data.optString("webSpeedUpHost"); |
| | | ConfigUtil.saveWebSpeedUpHost(getApplicationContext(), webSpeedUpHost); |
| | | //设置我的页面banner |
| | | ConfigUtil.saveMinePageBanner(getApplicationContext(), data.optString("minePageBanner")); |
| | | |
| | | ConfigUtil.savePlayerJumpOutProtocolPrefix(getApplicationContext(), data.optString("jumpAppProtocolPrefix")); |
| | | |
| | | //保存购买记录 |
| | | ConfigUtil.saveBuyRecordUrl(getApplicationContext(), data.optString("buyRecordUrl")); |
| | | |
| | | //是否正在上线 |
| | | ConfigUtil.saveOnLining(getApplicationContext(), data.optBoolean("onLining")); |
| | | |
| | | // 设置哀悼模式 |
| | | ConfigUtil.saveAiDaoMode(getApplicationContext(), data.optBoolean("aiDaoMode")); |
| | | |
| | | |
| | | //保存免广告权益持续时间 |
| | | AdUtil.setPPTVNoAdRewardHour(getApplicationContext(), pptvNoAdRewardHour); |
| | | |
| | | AdUtil.saveAdConfig(getApplicationContext(), ad); |
| | | AdUtil.AD_TYPE splash = AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splash); |
| | | //是否在上线 |
| | | if (AdUtil.getAdType(getApplicationContext(), AdPositionEnum.splashHotStart) == null) { |
| | | KSConstant.PID_FEED = 8010000022L; |
| | | KSConstant.PID_FULL_VIDEO = 8010000015L; |
| | | KSConstant.PID_SHORT_VIDEO = 8010000036L; |
| | | //广告下载二次确认框 |
| | | } |
| | | |
| | | |
| | | String pid = AdUtil.getAdPid(getApplicationContext(), AdPositionEnum.splash); |
| | | if (StringUtils.isBlank(pid)) { |
| | | if (splash != null) { |
| | | if (splash == AdUtil.AD_TYPE.csj) { |
| | | pid = CSJConstant.SPLASH_AD; |
| | | } else if (splash == AdUtil.AD_TYPE.gdt) { |
| | | pid = BeibeiConstant.GDT_SPLASH_POSITION_ID; |
| | | } |
| | | } |
| | | } |
| | | ConfigUtil.saveVipLink(getApplicationContext(), vipLink); |
| | | loadSplashAd(splash, pid); |
| | | } |
| | | } else { |
| | | loadSplashAd(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccess(int statusCode, Header[] headers, String responseString) { |
| | | super.onSuccess(statusCode, headers, responseString); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) { |
| | | super.onFailure(statusCode, headers, responseString, throwable); |
| | | loadSplashAd(AdUtil.AD_TYPE.csj, CSJConstant.SPLASH_AD); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | }, 1000); |
| | | |
| | | } |
| | | |
| | | |
| | | Dialog mDialog; |
| | | AlertDialog alertDialog; |
| | |
| | | if (requestCode == REQUEST_CODE) { |
| | | for (int i = 0; i < permissions.length; i++) { |
| | | if (grantResults[i] == PERMISSION_GRANTED) {//选择了“始终允许” |
| | | myRequetPermission(); |
| | | } else { |
| | | if (!ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[i])) {//用户选择了禁止不再询问 |
| | | AlertDialog.Builder builder = new AlertDialog.Builder(SplashActivity.this); |
| | | builder.setTitle("权限请求") |
| | | .setMessage("当前应用缺少必要的权限\n请点击设置-权限 打开电话和存储权限,以正常使用APP的功能") |
| | | .setPositiveButton("去设置", new DialogInterface.OnClickListener() { |
| | | public void onClick(DialogInterface dialog, int id) { |
| | | if (mDialog != null && mDialog.isShowing()) { |
| | | mDialog.dismiss(); |
| | | } |
| | | Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | Uri uri = Uri.fromParts("package", getPackageName(), null);//注意就是"package",不用改成自己的包名 |
| | | intent.setData(uri); |
| | | startActivityForResult(intent, REQUEST_CODE); |
| | | } |
| | | }); |
| | | mDialog = builder.create(); |
| | | mDialog.setCanceledOnTouchOutside(false); |
| | | mDialog.show(); |
| | | } else {//选择禁止 |
| | | AlertDialog.Builder builder = new AlertDialog.Builder(this); |
| | | builder.setTitle("权限请求") |
| | | .setMessage("点击允许才可以使用哦") |
| | | .setPositiveButton("去允许", new DialogInterface.OnClickListener() { |
| | | public void onClick(DialogInterface dialog, int id) { |
| | | if (alertDialog != null && alertDialog.isShowing()) { |
| | | alertDialog.dismiss(); |
| | | } |
| | | ActivityCompat.requestPermissions(SplashActivity.this, |
| | | new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_CODE); |
| | | } |
| | | }); |
| | | alertDialog = builder.create(); |
| | | alertDialog.setCanceledOnTouchOutside(false); |
| | | alertDialog.show(); |
| | | } |
| | | |
| | | init(); |
| | | } else { |
| | | //拒绝了授权 |
| | | if (grantResults[i] == PERMISSION_DENIED) { |
| | | SharedPreferences sharedPreferences = getSharedPreferences("permission", Context.MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sharedPreferences.edit(); |
| | | editor.putBoolean("show", false); |
| | | editor.commit(); |
| | | } |
| | | next(); |
| | | // if (!ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[i])) {//用户选择了禁止不再询问 |
| | | // AlertDialog.Builder builder = new AlertDialog.Builder(SplashActivity.this); |
| | | // builder.setTitle("权限请求") |
| | | // .setMessage("当前应用缺少必要的权限\n请点击设置-权限 打开电话和存储权限,以正常使用APP的功能") |
| | | // .setPositiveButton("去设置", new DialogInterface.OnClickListener() { |
| | | // public void onClick(DialogInterface dialog, int id) { |
| | | // if (mDialog != null && mDialog.isShowing()) { |
| | | // mDialog.dismiss(); |
| | | // } |
| | | // Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| | | // Uri uri = Uri.fromParts("package", getPackageName(), null);//注意就是"package",不用改成自己的包名 |
| | | // intent.setData(uri); |
| | | // startActivityForResult(intent, REQUEST_CODE); |
| | | // } |
| | | // }); |
| | | // mDialog = builder.create(); |
| | | // mDialog.setCanceledOnTouchOutside(false); |
| | | // mDialog.show(); |
| | | // } else {//选择禁止 |
| | | // AlertDialog.Builder builder = new AlertDialog.Builder(this); |
| | | // builder.setTitle("权限请求") |
| | | // .setMessage("点击允许才可以使用哦") |
| | | // .setPositiveButton("去允许", new DialogInterface.OnClickListener() { |
| | | // public void onClick(DialogInterface dialog, int id) { |
| | | // if (alertDialog != null && alertDialog.isShowing()) { |
| | | // alertDialog.dismiss(); |
| | | // } |
| | | // ActivityCompat.requestPermissions(SplashActivity.this, |
| | | // new String[]{Manifest.permission.READ_PHONE_STATE}, REQUEST_CODE); |
| | | // } |
| | | // }); |
| | | // alertDialog = builder.create(); |
| | | // alertDialog.setCanceledOnTouchOutside(false); |
| | | // alertDialog.show(); |
| | | // } |
| | | } |
| | | } |
| | | } |
| | |
| | | @Override |
| | | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| | | super.onActivityResult(requestCode, resultCode, data); |
| | | if (requestCode == REQUEST_CODE) { |
| | | myRequetPermission();//由于不知道是否选择了允许所以需要再次判断 |
| | | } |
| | | } |
| | | |
| | | |