| | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.appcompat.app.AppCompatActivity; |
| | | import androidx.core.app.ActivityCompat; |
| | | import androidx.core.content.ContextCompat; |
| | | |
| | | import static android.content.pm.PackageManager.PERMISSION_DENIED; |
| | | import static android.content.pm.PackageManager.PERMISSION_GRANTED; |
| | | |
| | | public class SplashActivity extends AppCompatActivity { |
| | |
| | | SharedPreferences sharedPreferences = getSharedPreferences("permission", Context.MODE_PRIVATE); |
| | | boolean showPermission = sharedPreferences.getBoolean("show", true); |
| | | |
| | | // if (1 > 0) { |
| | | // toMainActivity(); |
| | | // return; |
| | | // } |
| | | |
| | | |
| | | if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PERMISSION_GRANTED && showPermission) { |
| | | ActivityCompat.requestPermissions(this, PERMISSIONS, REQUEST_CODE); |
| | | } else { |
| | | next(); |
| | | } |
| | | } |
| | | |
| | | |
| | | void next() { |
| | | MyApplication.init(MyApplication.application, new MyApplication.InitListener() { |
| | | @Override |
| | | public void onFinish() { |
| | | |
| | | } |
| | | }); |
| | | |
| | | if (1 > 0) { |
| | | vg_ad.postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | toMainActivity(); |
| | | } |
| | | },3000); |
| | | |
| | | return; |
| | | } |
| | | |
| | | |
| | | int delayMs = 1; |
| | | vg_ad.postDelayed(new Runnable() { |
| | | @Override |
| | |
| | | |
| | | } |
| | | }, delayMs); |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | * 加载开屏广告 |
| | | */ |
| | | private void loadSplashAd() { |
| | | |
| | | AdUtil.AD_TYPE splashType = AdUtil.getAdType(getApplicationContext(), ""); |
| | | if (splashType == null) { |
| | | vg_ad.postDelayed(new Runnable() { |
| | |
| | | finish(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| | | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| | | if (requestCode == REQUEST_CODE) { |
| | | for (int i = 0; i < permissions.length; i++) { |
| | | if (grantResults[i] == PERMISSION_GRANTED) {//选择了“始终允许” |
| | | requetPermission(); |
| | | } 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(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |