作者 潘达康

1、加入获取渠道标识

2、加入Action,改为隐式启动
3、更改包名为com.qw7277.game、显示名为7277游戏
@@ -3,17 +3,15 @@ plugins { @@ -3,17 +3,15 @@ plugins {
3 } 3 }
4 4
5 android { 5 android {
6 - namespace 'com.qiwan.gamebox' 6 + namespace 'com.qw7277.game'
7 compileSdk 29 7 compileSdk 29
8 8
9 defaultConfig { 9 defaultConfig {
10 - applicationId "com.qiwan.gamebox" 10 + applicationId "com.qw7277.game"
11 minSdk 21 11 minSdk 21
12 targetSdk 29 12 targetSdk 29
13 versionCode 1 13 versionCode 1
14 versionName "1.0" 14 versionName "1.0"
15 -  
16 - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"  
17 } 15 }
18 16
19 buildTypes { 17 buildTypes {
@@ -26,6 +24,9 @@ android { @@ -26,6 +24,9 @@ android {
26 sourceCompatibility JavaVersion.VERSION_1_8 24 sourceCompatibility JavaVersion.VERSION_1_8
27 targetCompatibility JavaVersion.VERSION_1_8 25 targetCompatibility JavaVersion.VERSION_1_8
28 } 26 }
  27 + lint {
  28 + baseline = file("lint-baseline.xml")
  29 + }
29 } 30 }
30 31
31 dependencies { 32 dependencies {
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<issues format="6" by="lint 7.3.1" type="baseline" client="gradle" dependencies="false" name="AGP (7.3.1)" variant="fatal" version="7.3.1">
  3 +
  4 + <issue
  5 + id="ExpiredTargetSdkVersion"
  6 + message="Google Play requires that apps target API level 31 or higher.&#xA;"
  7 + errorLine1=" targetSdkVersion 29"
  8 + errorLine2=" ~~~~~~~~~~~~~~~~~~~">
  9 + <location
  10 + file="build.gradle"
  11 + line="12"
  12 + column="9"/>
  13 + </issue>
  14 +
  15 +</issues>
@@ -11,11 +11,13 @@ @@ -11,11 +11,13 @@
11 tools:targetApi="31"> 11 tools:targetApi="31">
12 12
13 <activity 13 <activity
14 - android:name="com.qiwan.gamebox.MainActivity" 14 + android:name=".MainActivity"
15 android:screenOrientation="portrait" 15 android:screenOrientation="portrait"
16 android:exported="true"> 16 android:exported="true">
17 <intent-filter> 17 <intent-filter>
  18 + <action android:name="com.qw7277.game.ACTION_START"/>
18 <action android:name="android.intent.action.MAIN" /> 19 <action android:name="android.intent.action.MAIN" />
  20 + <category android:name="android.intent.category.DEFAULT"/>
19 <category android:name="android.intent.category.LAUNCHER" /> 21 <category android:name="android.intent.category.LAUNCHER" />
20 </intent-filter> 22 </intent-filter>
21 <meta-data 23 <meta-data
1 -package com.qiwan.gamebox; 1 +package com.qw7277.game;
2 2
3 import android.app.Activity; 3 import android.app.Activity;
  4 +import android.content.Context;
4 import android.graphics.Color; 5 import android.graphics.Color;
5 import android.os.Build; 6 import android.os.Build;
6 import android.os.Bundle; 7 import android.os.Bundle;
  8 +import android.text.TextUtils;
  9 +import android.util.Log;
7 import android.view.WindowManager; 10 import android.view.WindowManager;
8 import android.webkit.WebSettings; 11 import android.webkit.WebSettings;
9 import android.webkit.WebView; 12 import android.webkit.WebView;
10 import android.widget.LinearLayout; 13 import android.widget.LinearLayout;
11 import android.widget.Toast; 14 import android.widget.Toast;
  15 +import com.qw7277.game.util.AppUtils;
12 16
13 import com.readystatesoftware.systembartint.SystemBarTintManager; 17 import com.readystatesoftware.systembartint.SystemBarTintManager;
14 18
15 public class MainActivity extends Activity { 19 public class MainActivity extends Activity {
  20 + private Context mContext;
16 private LinearLayout mLlRoot; 21 private LinearLayout mLlRoot;
17 private WebView mWebView; 22 private WebView mWebView;
18 private SystemBarTintManager mTintManager; 23 private SystemBarTintManager mTintManager;
19 private String mUrl = "https://cdn.kky.cn/yxhz/index.html#/home"; 24 private String mUrl = "https://cdn.kky.cn/yxhz/index.html#/home";
  25 + private String mParams="";
20 26
21 @Override 27 @Override
22 protected void onCreate(Bundle savedInstanceState) { 28 protected void onCreate(Bundle savedInstanceState) {
23 super.onCreate(savedInstanceState); 29 super.onCreate(savedInstanceState);
  30 + mContext = this;
24 mTintManager = new SystemBarTintManager(this); 31 mTintManager = new SystemBarTintManager(this);
25 mTintManager.setStatusBarTintEnabled(false); 32 mTintManager.setStatusBarTintEnabled(false);
26 mTintManager.setNavigationBarTintEnabled(true); 33 mTintManager.setNavigationBarTintEnabled(true);
@@ -36,13 +43,13 @@ public class MainActivity extends Activity { @@ -36,13 +43,13 @@ public class MainActivity extends Activity {
36 initView(); 43 initView();
37 initWebView(); 44 initWebView();
38 initData(); 45 initData();
39 -  
40 - mWebView.loadUrl(mUrl); 46 + Log.d("ZhenWan", mUrl+"?"+mParams);
  47 + mWebView.loadUrl(mUrl+"?"+mParams);
41 } 48 }
42 49
43 private void initView() { 50 private void initView() {
44 mLlRoot = findViewById(R.id.ll_root); 51 mLlRoot = findViewById(R.id.ll_root);
45 - mLlRoot.setPadding(0, mTintManager.getConfig().getStatusBarHeight(), 0, mTintManager.getConfig().getNavigationBarHeight()+20); 52 + mLlRoot.setPadding(0, mTintManager.getConfig().getStatusBarHeight(), 0, mTintManager.getConfig().getNavigationBarHeight() + 20);
46 mWebView = findViewById(R.id.webview); 53 mWebView = findViewById(R.id.webview);
47 } 54 }
48 55
@@ -58,21 +65,21 @@ public class MainActivity extends Activity { @@ -58,21 +65,21 @@ public class MainActivity extends Activity {
58 65
59 private void initData() { 66 private void initData() {
60 Bundle extras = getIntent().getExtras(); 67 Bundle extras = getIntent().getExtras();
61 - if (extras != null) {  
62 - if (extras.containsKey("AuthParams")) {  
63 - String parameterValue = extras.getString("AuthParams");  
64 - mUrl = mUrl + "?" + parameterValue;  
65 - } 68 + if (extras != null && extras.containsKey("AuthParams")) {
  69 + mParams = extras.getString("AuthParams");
66 } 70 }
  71 + String cid = AppUtils.getLogicChannel(mContext, "sid");
  72 + mParams += (TextUtils.isEmpty(mParams) ? "" : "&") + "cid=" + cid;
67 } 73 }
68 74
69 private long mBackPressedTime = 0; 75 private long mBackPressedTime = 0;
  76 +
70 @Override 77 @Override
71 public void onBackPressed() { 78 public void onBackPressed() {
72 if (mWebView != null && mWebView.canGoBack()) { 79 if (mWebView != null && mWebView.canGoBack()) {
73 mWebView.goBack(); 80 mWebView.goBack();
74 } else { 81 } else {
75 - if(System.currentTimeMillis() - mBackPressedTime > 2000) { 82 + if (System.currentTimeMillis() - mBackPressedTime > 2000) {
76 Toast.makeText(this, "再按一次退出应用", Toast.LENGTH_SHORT).show(); 83 Toast.makeText(this, "再按一次退出应用", Toast.LENGTH_SHORT).show();
77 mBackPressedTime = System.currentTimeMillis(); 84 mBackPressedTime = System.currentTimeMillis();
78 } else { 85 } else {
  1 +package com.qw7277.game.util;
  2 +
  3 +import android.content.Context;
  4 +import android.content.pm.ApplicationInfo;
  5 +
  6 +import java.io.IOException;
  7 +import java.util.Enumeration;
  8 +import java.util.regex.Matcher;
  9 +import java.util.regex.Pattern;
  10 +import java.util.zip.ZipEntry;
  11 +import java.util.zip.ZipFile;
  12 +
  13 +public class AppUtils {
  14 + public static String getLogicChannel(Context context, String prefix) {
  15 + try {
  16 + ApplicationInfo appInfo = context.getApplicationInfo();
  17 + String sourceDir = appInfo.sourceDir;
  18 + String key = "META-INF/" + prefix;
  19 + try (ZipFile zip = new ZipFile(sourceDir)) {
  20 + Enumeration<? extends ZipEntry> entries = zip.entries();
  21 + while (entries.hasMoreElements()) {
  22 + ZipEntry entry = entries.nextElement();
  23 + String entryName = entry.getName();
  24 + if (entryName.startsWith(key)) {
  25 + String sidPattern = prefix + "_(\\d+)";
  26 + Pattern pattern = Pattern.compile(sidPattern);
  27 + Matcher matcher = pattern.matcher(entryName);
  28 + if (matcher.find()) {
  29 + return matcher.group(1); // 返回匹配到的数字部分
  30 + }
  31 + }
  32 + }
  33 + }
  34 + } catch (IOException e) {
  35 + e.printStackTrace();
  36 + }
  37 + // 获取不到默认返回1
  38 + return "1";
  39 + }
  40 +}
1 <resources> 1 <resources>
2 - <string name="app_name">7277</string> 2 + <string name="app_name">7277手游</string>
3 </resources> 3 </resources>