Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
M
MusicBigWatermelon
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
MusicBigWatermelon
Commits
e9274b23
Commit
e9274b23
authored
Aug 04, 2021
by
LiLiuZhou
Browse files
Options
Browse Files
Download
Plain Diff
1
parents
6a21e725
71cb07ae
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
711 deletions
+15
-711
UnityPhoneUtils.java
Assets/Base/UnityTool/Plugins/Android/UnityPhoneUtils.java
+0
-663
UnityWxLoginUtil.java
Assets/Base/UnityTool/Plugins/Android/UnityWxLoginUtil.java
+0
-12
WXEntryActivity.java
Assets/Base/UnityTool/Plugins/Android/WXEntryActivity.java
+1
-1
AndroidManifest.xml
Assets/Plugins/Android/AndroidManifest.xml
+2
-17
GameController.cs
Assets/Scripts/Controllers/GameController.cs
+8
-17
HomeInfoControl.cs
Assets/Scripts/Main/HomeInfoControl.cs
+4
-1
No files found.
Assets/Base/UnityTool/Plugins/Android/UnityPhoneUtils.java
View file @
e9274b23
...
@@ -66,193 +66,6 @@ public class UnityPhoneUtils {
...
@@ -66,193 +66,6 @@ public class UnityPhoneUtils {
}
}
}
}
/**
* 获取application中指定的meta-data 调用方法时key就是UMENG_CHANNEL
*
* @return 如果没有获取成功(没有对应值 , 或者异常),则返回值为空
*/
public
String
getChannel
(
Context
ctx
)
{
if
(
ctx
==
null
||
TextUtils
.
isEmpty
(
"UMENG_CHANNEL"
))
{
return
""
;
}
String
resultData
=
""
;
try
{
PackageManager
packageManager
=
ctx
.
getPackageManager
();
if
(
packageManager
!=
null
)
{
ApplicationInfo
applicationInfo
=
packageManager
.
getApplicationInfo
(
ctx
.
getPackageName
(),
PackageManager
.
GET_META_DATA
);
if
(
applicationInfo
!=
null
)
{
if
(
applicationInfo
.
metaData
!=
null
)
{
resultData
=
applicationInfo
.
metaData
.
getString
(
"UMENG_CHANNEL"
);
}
}
}
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
resultData
;
}
/**
* 获取当前的运营商
*
* @param context
* @return 运营商名字
*/
public
String
getOperator
(
Context
context
)
{
String
ProvidersName
=
""
;
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
String
IMSI
=
""
;
try
{
IMSI
=
telephonyManager
.
getSubscriberId
();
}
catch
(
SecurityException
e
)
{
// Toast.makeText(context, "请开启读取手机权限", Toast.LENGTH_SHORT).show()
return
"0"
;
}
if
(
IMSI
!=
null
)
{
if
(
IMSI
.
startsWith
(
"46000"
)
||
IMSI
.
startsWith
(
"46002"
)
||
IMSI
.
startsWith
(
"46007"
))
{
// ProvidersName = "移动";
ProvidersName
=
"1"
;
}
else
if
(
IMSI
.
startsWith
(
"46001"
)
||
IMSI
.
startsWith
(
"46006"
))
{
ProvidersName
=
"2"
;
// ProvidersName = "联通";
}
else
if
(
IMSI
.
startsWith
(
"46003"
))
{
ProvidersName
=
"3"
;
// ProvidersName = "电信";
}
return
ProvidersName
;
}
else
{
return
"0"
;
// return "没有获取到sim卡信息";
}
}
public
String
getUserAgent
(
Context
context
)
{
String
userAgent
=
""
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
JELLY_BEAN_MR1
)
{
try
{
userAgent
=
WebSettings
.
getDefaultUserAgent
(
context
);
}
catch
(
Exception
e
)
{
userAgent
=
System
.
getProperty
(
"http.agent"
);
}
}
else
{
userAgent
=
System
.
getProperty
(
"http.agent"
);
}
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
,
length
=
userAgent
.
length
();
i
<
length
;
i
++)
{
char
c
=
userAgent
.
charAt
(
i
);
if
(
c
<=
'\u001f'
||
c
>=
'\u007f'
)
{
sb
.
append
(
String
.
format
(
"\\u%04x"
,
(
int
)
c
));
}
else
{
sb
.
append
(
c
);
}
}
return
sb
.
toString
();
}
/**
* @Description: 获取屏幕的宽度
* @param: context
* @return: int
*/
public
int
getScreenWidth
(
Context
context
)
{
return
context
.
getResources
().
getDisplayMetrics
().
widthPixels
;
}
/**
* 获取屏幕高度
*
* @param context
* @return int
*/
public
int
getScreenHeight
(
Context
context
)
{
return
context
.
getResources
().
getDisplayMetrics
().
heightPixels
;
}
/**
* 获取屏幕高度
*
* @param context
* @return int
*/
public
int
getScreenDpi
(
Context
context
)
{
return
context
.
getResources
().
getDisplayMetrics
().
densityDpi
;
}
/**
* 获取屏幕尺寸
*
* @param context
* @return int
*/
public
double
getScreenSize
(
Activity
context
)
{
double
mInch
=
0
;
try
{
int
realWidth
=
0
,
realHeight
=
0
;
Display
display
=
context
.
getWindowManager
().
getDefaultDisplay
();
DisplayMetrics
metrics
=
new
DisplayMetrics
();
display
.
getMetrics
(
metrics
);
if
(
Build
.
VERSION
.
SDK_INT
>=
17
)
{
Point
size
=
new
Point
();
display
.
getRealSize
(
size
);
realWidth
=
size
.
x
;
realHeight
=
size
.
y
;
}
else
if
(
Build
.
VERSION
.
SDK_INT
<
17
&&
Build
.
VERSION
.
SDK_INT
>=
14
)
{
Method
mGetRawH
=
Display
.
class
.
getMethod
(
"getRawHeight"
);
Method
mGetRawW
=
Display
.
class
.
getMethod
(
"getRawWidth"
);
realWidth
=
(
Integer
)
mGetRawW
.
invoke
(
display
);
realHeight
=
(
Integer
)
mGetRawH
.
invoke
(
display
);
}
else
{
realWidth
=
metrics
.
widthPixels
;
realHeight
=
metrics
.
heightPixels
;
}
mInch
=
formatDouble
(
Math
.
sqrt
((
realWidth
/
metrics
.
xdpi
)
*
(
realWidth
/
metrics
.
xdpi
)
+
(
realHeight
/
metrics
.
ydpi
)
*
(
realHeight
/
metrics
.
ydpi
)),
1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
mInch
;
}
/**
* Double类型保留指定位数的小数,返回double类型(四舍五入)
* newScale 为指定的位数
*/
private
static
double
formatDouble
(
double
d
,
int
newScale
)
{
BigDecimal
bd
=
new
BigDecimal
(
d
);
return
bd
.
setScale
(
newScale
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
}
/**
* 获取屏幕分辨率
*
* @param context
* @return int
*/
public
float
getScreenDensity
(
Context
context
)
{
return
context
.
getResources
().
getDisplayMetrics
().
density
;
}
public
String
getSVN
()
{
return
android
.
os
.
Build
.
VERSION
.
SDK_INT
+
""
;
}
/**
* 获取设备型号
*
* @return 设备型号
*/
public
String
getModel
()
{
String
model
=
Build
.
MODEL
;
return
model
;
}
/**
/**
* 获取App版本码
* 获取App版本码
*
*
...
@@ -287,89 +100,6 @@ public class UnityPhoneUtils {
...
@@ -287,89 +100,6 @@ public class UnityPhoneUtils {
return
versionName
;
return
versionName
;
}
}
/**
* 获取应用程序名称
*/
public
String
getAppName
(
Context
context
)
{
try
{
PackageManager
packageManager
=
context
.
getPackageManager
();
PackageInfo
packageInfo
=
packageManager
.
getPackageInfo
(
context
.
getPackageName
(),
0
);
int
labelRes
=
packageInfo
.
applicationInfo
.
labelRes
;
return
context
.
getResources
().
getString
(
labelRes
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
private
String
GetIp
()
{
try
{
for
(
Enumeration
<
NetworkInterface
>
en
=
NetworkInterface
.
getNetworkInterfaces
();
en
.
hasMoreElements
();
)
{
NetworkInterface
intf
=
en
.
nextElement
();
for
(
Enumeration
<
InetAddress
>
enumIpAddr
=
intf
.
getInetAddresses
();
enumIpAddr
.
hasMoreElements
();
)
{
InetAddress
inetAddress
=
enumIpAddr
.
nextElement
();
if
(!
inetAddress
.
isLoopbackAddress
()
&&
!
inetAddress
.
isLinkLocalAddress
())
{
return
inetAddress
.
getHostAddress
().
toString
();
}
}
}
}
catch
(
SocketException
ex
)
{
ex
.
printStackTrace
();
}
return
""
;
}
/**
* 获取IP地址
* <p>
* 需添加权限 `<uses-permission android:name="android.permission.INTERNET"/>`
*
* @param useIPv4 是否用IPv4
* @return IP地址
*/
public
String
getIPAddress
(
boolean
useIPv4
)
{
if
(
useIPv4
)
{
return
GetIp
();
}
try
{
Enumeration
<
NetworkInterface
>
nis
=
NetworkInterface
.
getNetworkInterfaces
();
while
(
nis
.
hasMoreElements
())
{
NetworkInterface
ni
=
nis
.
nextElement
();
if
(
ni
.
isUp
())
{
continue
;
}
Enumeration
<
InetAddress
>
addresses
=
ni
.
getInetAddresses
();
while
(
addresses
.
hasMoreElements
())
{
InetAddress
inetAddress
=
addresses
.
nextElement
();
if
(!
inetAddress
.
isLoopbackAddress
())
{
String
hostAddress
=
inetAddress
.
getHostAddress
();
boolean
isIPv4
=
hostAddress
.
indexOf
(
':'
)
<
0
;
if
(
useIPv4
)
{
if
(
isIPv4
)
return
hostAddress
;
}
else
{
if
(!
isIPv4
)
{
int
index
=
hostAddress
.
indexOf
(
'%'
);
if
(
index
<
0
)
{
return
hostAddress
.
toUpperCase
();
}
else
{
return
hostAddress
.
substring
(
0
,
index
).
toUpperCase
();
}
}
}
}
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
""
;
}
public
String
getDeviceId
(
Context
context
)
{
public
String
getDeviceId
(
Context
context
)
{
return
getMd5Value
(
getAndroidID
(
context
)
+
getImei
(
context
));
return
getMd5Value
(
getAndroidID
(
context
)
+
getImei
(
context
));
...
@@ -409,397 +139,4 @@ public class UnityPhoneUtils {
...
@@ -409,397 +139,4 @@ public class UnityPhoneUtils {
}
}
}
}
public
String
getMac
(
Context
context
)
{
String
strMac
=
""
;
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
{
strMac
=
getLocalMacAddressFromWifiInfo
(
context
);
return
strMac
;
}
else
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
N
&&
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
M
)
{
strMac
=
getMacAddress
(
context
);
return
strMac
;
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
if
(!
TextUtils
.
isEmpty
(
getMacAddress
(
context
)))
{
strMac
=
getMacAddress
(
context
);
return
strMac
;
}
else
if
(!
TextUtils
.
isEmpty
(
getMachineHardwareAddress
()))
{
strMac
=
getMachineHardwareAddress
();
return
strMac
;
}
else
{
strMac
=
getLocalMacAddressFromBusybox
();
return
strMac
;
}
}
return
""
;
}
public
String
getUUID
()
{
return
UUID
.
randomUUID
().
toString
();
}
public
String
getLocalMacAddressFromWifiInfo
(
Context
context
)
{
WifiManager
wifi
=
(
WifiManager
)
context
.
getSystemService
(
context
.
WIFI_SERVICE
);
WifiInfo
info
=
wifi
.
getConnectionInfo
();
String
str
=
info
.
getMacAddress
();
if
(
str
==
null
)
{
str
=
""
;
}
return
str
;
}
public
String
getLocalMacAddressFromBusybox
()
{
String
result
=
""
;
String
Mac
=
""
;
result
=
callCmd
(
"busybox ifconfig"
,
"HWaddr"
);
// 如果返回的result == null,则说明网络不可取
if
(
TextUtils
.
isEmpty
(
result
))
{
// return "网络异常";
return
""
;
}
// 对该行数据进行解析
// 例如:eth0 Link encap:Ethernet HWaddr 00:16:E8:3E:DF:67
if
(
result
.
length
()
>
0
&&
result
.
contains
(
"HWaddr"
))
{
Mac
=
result
.
substring
(
result
.
indexOf
(
"HWaddr"
)
+
6
,
result
.
length
()
-
1
);
result
=
Mac
;
}
return
result
;
}
private
String
callCmd
(
String
cmd
,
String
filter
)
{
String
result
=
""
;
String
line
=
""
;
try
{
Process
proc
=
Runtime
.
getRuntime
().
exec
(
cmd
);
InputStreamReader
mInputStream
=
new
InputStreamReader
(
proc
.
getInputStream
());
BufferedReader
br
=
new
BufferedReader
(
mInputStream
);
while
((
line
.
equals
(
br
.
readLine
()))
&&
!
line
.
contains
(
filter
))
{
result
+=
line
;
if
(
TextUtils
.
isEmpty
(
result
))
{
return
""
;
}
}
result
=
line
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
/**
* android 7.0及以上 (2)扫描各个网络接口获取mac地址
*
*/
/**
* 获取设备HardwareAddress地址
*
* @return
*/
public
String
getMachineHardwareAddress
()
{
Enumeration
<
NetworkInterface
>
interfaces
=
null
;
try
{
interfaces
=
NetworkInterface
.
getNetworkInterfaces
();
}
catch
(
SocketException
e
)
{
e
.
printStackTrace
();
}
String
hardWareAddress
=
""
;
NetworkInterface
iF
=
null
;
if
(
interfaces
==
null
)
{
return
""
;
}
while
(
interfaces
.
hasMoreElements
())
{
iF
=
interfaces
.
nextElement
();
try
{
hardWareAddress
=
bytesToString
(
iF
.
getHardwareAddress
());
if
(
hardWareAddress
!=
null
)
break
;
}
catch
(
SocketException
e
)
{
e
.
printStackTrace
();
}
}
return
hardWareAddress
;
}
/***
* byte转为String
*
* @param bytes
* @return
*/
private
String
bytesToString
(
byte
[]
bytes
)
{
if
(
bytes
==
null
||
bytes
.
length
<=
0
)
{
return
""
;
}
StringBuilder
buf
=
new
StringBuilder
();
for
(
byte
b
:
bytes
)
{
buf
.
append
(
String
.
format
(
"%02X:"
,
b
));
}
if
(
buf
.
length
()
>
0
)
{
buf
.
deleteCharAt
(
buf
.
length
()
-
1
);
}
return
buf
.
toString
();
}
private
String
getMacAddress
(
Context
context
)
{
// 如果是6.0以下,直接通过wifimanager获取
if
(
Build
.
VERSION
.
SDK_INT
<
Build
.
VERSION_CODES
.
M
)
{
String
macAddress0
=
getMacAddress0
(
context
);
if
(!
TextUtils
.
isEmpty
(
macAddress0
))
{
return
macAddress0
;
}
}
String
str
=
""
;
String
macSerial
=
""
;
try
{
Process
pp
=
Runtime
.
getRuntime
().
exec
(
"cat /sys/class/net/wlan0/address"
);
InputStreamReader
ir
=
new
InputStreamReader
(
pp
.
getInputStream
());
LineNumberReader
input
=
new
LineNumberReader
(
ir
);
while
(
null
!=
str
)
{
str
=
input
.
readLine
();
if
(
str
!=
null
)
{
macSerial
=
str
.
trim
();
break
;
}
}
}
catch
(
Exception
ex
)
{
}
if
(
macSerial
==
null
||
""
==
macSerial
)
{
try
{
String
loadFileAsString
=
loadFileAsString
(
"/sys/class/net/eth0/address"
);
if
(!
TextUtils
.
isEmpty
(
loadFileAsString
)
&&
loadFileAsString
.
length
()
>
17
)
{
return
loadFileAsString
.
toUpperCase
().
substring
(
0
,
17
);
}
else
{
return
loadFileAsString
.
toUpperCase
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
macSerial
;
}
private
String
getMacAddress0
(
Context
context
)
{
if
(
isAccessWifiStateAuthorized
(
context
))
{
WifiManager
wifiMgr
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
WifiInfo
wifiInfo
=
null
;
try
{
wifiInfo
=
wifiMgr
.
getConnectionInfo
();
return
wifiInfo
.
getMacAddress
();
}
catch
(
Exception
e
)
{
}
}
return
""
;
}
/**
* Check whether accessing wifi state is permitted
*
* @param context
* @return
*/
private
boolean
isAccessWifiStateAuthorized
(
Context
context
)
{
if
(
PackageManager
.
PERMISSION_GRANTED
==
context
.
checkCallingOrSelfPermission
(
"android.permission.ACCESS_WIFI_STATE"
)
)
{
return
true
;
}
else
return
false
;
}
private
String
loadFileAsString
(
String
fileName
)
{
try
{
FileReader
reader
=
new
FileReader
(
fileName
);
String
text
=
loadReaderAsString
(
reader
);
reader
.
close
();
return
text
;
}
catch
(
Exception
e
)
{
return
""
;
}
}
private
String
loadReaderAsString
(
Reader
reader
)
throws
IOException
{
StringBuilder
builder
=
new
StringBuilder
();
char
[]
buffer
=
new
char
[
4096
];
int
readLength
=
reader
.
read
(
buffer
);
while
(
readLength
>=
0
)
{
builder
.
append
(
buffer
,
0
,
readLength
);
readLength
=
reader
.
read
(
buffer
);
}
return
builder
.
toString
();
}
/**
* 获取当前网络类型
* <p>
* 需添加权限 `<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>`
*
* @return 网络类型
*/
private
enum
NetworkType
{
NETWORK_WIFI
,
NETWORK_4G
,
NETWORK_3G
,
NETWORK_2G
,
NETWORK_UNKNOWN
,
NETWORK_NO
}
public
String
getNetwork
(
Context
context
)
{
// String s = "";
// switch (getNetworkType(context)) {
// case NETWORK_2G:
// s = "2";
// break;
// case NETWORK_3G:
// s = "3";
// break;
// case NETWORK_4G:
// s = "4";
// break;
// case NETWORK_WIFI:
// s = "1";
// break;
// default:
// s = "5";
// break;
// }
return
getNetworkType
(
context
).
toString
();
}
public
NetworkType
getNetworkType
(
Context
context
)
{
NetworkType
netType
=
NetworkType
.
NETWORK_NO
;
NetworkInfo
info
=
getActiveNetworkInfo
(
context
);
if
(
info
!=
null
&&
info
.
isAvailable
())
{
if
(
info
.
getType
()
==
ConnectivityManager
.
TYPE_WIFI
)
{
netType
=
NetworkType
.
NETWORK_WIFI
;
}
else
if
(
info
.
getType
()
==
ConnectivityManager
.
TYPE_MOBILE
)
{
switch
(
info
.
getSubtype
())
{
case
TelephonyManager
.
NETWORK_TYPE_GSM
:
case
TelephonyManager
.
NETWORK_TYPE_GPRS
:
case
TelephonyManager
.
NETWORK_TYPE_CDMA
:
case
TelephonyManager
.
NETWORK_TYPE_EDGE
:
case
TelephonyManager
.
NETWORK_TYPE_1xRTT
:
case
TelephonyManager
.
NETWORK_TYPE_IDEN
:
netType
=
NetworkType
.
NETWORK_2G
;
break
;
case
TelephonyManager
.
NETWORK_TYPE_TD_SCDMA
:
case
TelephonyManager
.
NETWORK_TYPE_EVDO_A
:
case
TelephonyManager
.
NETWORK_TYPE_UMTS
:
case
TelephonyManager
.
NETWORK_TYPE_EVDO_0
:
case
TelephonyManager
.
NETWORK_TYPE_HSDPA
:
case
TelephonyManager
.
NETWORK_TYPE_HSUPA
:
case
TelephonyManager
.
NETWORK_TYPE_HSPA
:
case
TelephonyManager
.
NETWORK_TYPE_EVDO_B
:
case
TelephonyManager
.
NETWORK_TYPE_EHRPD
:
case
TelephonyManager
.
NETWORK_TYPE_HSPAP
:
netType
=
NetworkType
.
NETWORK_3G
;
break
;
case
TelephonyManager
.
NETWORK_TYPE_IWLAN
:
case
TelephonyManager
.
NETWORK_TYPE_LTE
:
netType
=
NetworkType
.
NETWORK_4G
;
break
;
default
:
String
subtypeName
=
info
.
getSubtypeName
();
if
(
subtypeName
.
equalsIgnoreCase
(
"TD-SCDMA"
)
||
subtypeName
.
equalsIgnoreCase
(
"WCDMA"
)
||
subtypeName
.
equalsIgnoreCase
(
"CDMA2000"
)
)
{
netType
=
NetworkType
.
NETWORK_3G
;
}
else
{
netType
=
NetworkType
.
NETWORK_UNKNOWN
;
}
break
;
}
}
else
{
netType
=
NetworkType
.
NETWORK_UNKNOWN
;
}
}
return
netType
;
}
/**
* 获取活动网络信息
* <p>
* 需添加权限 `<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>`
*
* @return NetworkInfo
*/
@SuppressLint
(
"MissingPermission"
)
private
NetworkInfo
getActiveNetworkInfo
(
Context
context
)
{
ConnectivityManager
manager
=
(
ConnectivityManager
)
context
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
try
{
return
manager
.
getActiveNetworkInfo
();
}
catch
(
Exception
e
)
{
return
null
;
}
}
private
String
buildMap
(
Map
<
String
,
String
>
map
)
{
StringBuffer
sb
=
new
StringBuffer
();
if
(
map
.
size
()
>
0
)
{
for
(
String
key
:
map
.
keySet
())
{
sb
.
append
(
key
+
"="
);
if
(
TextUtils
.
isEmpty
(
map
.
get
(
key
)))
{
sb
.
append
(
"&"
);
}
else
{
String
value
=
map
.
get
(
key
);
try
{
value
=
URLEncoder
.
encode
(
value
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
sb
.
append
(
value
+
"&"
);
}
}
}
return
sb
.
toString
();
}
@SuppressLint
(
"MissingPermission"
)
private
String
getBSSID
(
Context
context
)
{
WifiManager
mWifiManager
=
(
WifiManager
)
context
.
getSystemService
(
Context
.
WIFI_SERVICE
);
WifiInfo
mWifiInfo
=
mWifiManager
.
getConnectionInfo
();
String
s
=
""
;
if
(
mWifiInfo
!=
null
)
{
s
=
mWifiInfo
.
getBSSID
();
}
return
s
;
}
/**
* 获取手机IMSI号
*/
@SuppressLint
(
"MissingPermission"
)
public
String
getIMSI
(
Context
context
)
{
try
{
TelephonyManager
mTelephonyMgr
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
return
mTelephonyMgr
.
getSubscriberId
();
}
catch
(
Exception
e
)
{
return
""
;
}
}
public
boolean
IsInstallApp
(
Context
context
,
String
pkgName
)
{
if
(
pkgName
==
null
||
pkgName
.
isEmpty
())
{
return
false
;
}
PackageInfo
packageInfo
;
try
{
packageInfo
=
context
.
getPackageManager
().
getPackageInfo
(
pkgName
,
0
);
}
catch
(
PackageManager
.
NameNotFoundException
e
)
{
packageInfo
=
null
;
e
.
printStackTrace
();
}
if
(
packageInfo
==
null
)
{
return
false
;
}
else
{
return
true
;
//true为安装了,false为未安装
}
}
}
}
Assets/Base/UnityTool/Plugins/Android/UnityWxLoginUtil.java
View file @
e9274b23
package
com
.
ym
.
unityandroid
;
package
com
.
ym
.
unityandroid
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.util.Log
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
com.tencent.mm.opensdk.modelmsg.SendAuth
;
import
com.tencent.mm.opensdk.modelmsg.SendAuth
;
import
com.tencent.mm.opensdk.openapi.IWXAPI
;
import
com.tencent.mm.opensdk.openapi.IWXAPI
;
import
com.tencent.mm.opensdk.openapi.WXAPIFactory
;
import
com.tencent.mm.opensdk.openapi.WXAPIFactory
;
import
com.unity3d.player.UnityPlayer
;
import
com.unity3d.player.UnityPlayer
;
import
com.ym.unityandroid.webview.UnityWebActivity
;
public
class
UnityWxLoginUtil
{
public
class
UnityWxLoginUtil
{
...
@@ -52,7 +49,6 @@ public class UnityWxLoginUtil {
...
@@ -52,7 +49,6 @@ public class UnityWxLoginUtil {
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(
api
.
isWXAppInstalled
()){
if
(
api
.
isWXAppInstalled
()){
Log
.
d
(
"wxw"
,
"wxwisWXAppInstalled1"
);
final
SendAuth
.
Req
req
=
new
SendAuth
.
Req
();
final
SendAuth
.
Req
req
=
new
SendAuth
.
Req
();
req
.
scope
=
"snsapi_userinfo"
;
req
.
scope
=
"snsapi_userinfo"
;
req
.
state
=
"wechat_sdk"
;
req
.
state
=
"wechat_sdk"
;
...
@@ -68,12 +64,4 @@ public class UnityWxLoginUtil {
...
@@ -68,12 +64,4 @@ public class UnityWxLoginUtil {
});
});
}
}
//打开H5页面
public
void
OpenH5Page
(
Activity
activity
,
String
url
,
String
title
){
Intent
intent
=
new
Intent
(
activity
,
UnityWebActivity
.
class
);
intent
.
putExtra
(
"url"
,
url
);
activity
.
startActivity
(
intent
);
}
}
}
Assets/Base/UnityTool/Plugins/Android/WXEntryActivity.java
View file @
e9274b23
package
com
.
ym
.
cydyj
.
wxapi
;
package
com
.
ym
.
pcdxg
.
wxapi
;
import
android.app.Activity
;
import
android.app.Activity
;
import
android.content.Intent
;
import
android.content.Intent
;
...
...
Assets/Plugins/Android/AndroidManifest.xml
View file @
e9274b23
...
@@ -11,11 +11,7 @@
...
@@ -11,11 +11,7 @@
<uses-permission
android:name=
"android.permission.REQUEST_INSTALL_PACKAGES"
/>
<uses-permission
android:name=
"android.permission.REQUEST_INSTALL_PACKAGES"
/>
<uses-permission
android:name=
"android.permission.READ_LOGS"
/>
<uses-permission
android:name=
"android.permission.READ_LOGS"
/>
<uses-permission
android:name=
"android.permission.GET_TASKS"
/>
<uses-permission
android:name=
"android.permission.GET_TASKS"
/>
<!--最好能提供的权限-->
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<!-- 如果有视频相关的广告且使用textureView播放,请务必添加,否则黑屏 -->
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<application
<application
android:icon=
"@drawable/app_icon"
android:icon=
"@drawable/app_icon"
...
@@ -41,20 +37,9 @@
...
@@ -41,20 +37,9 @@
<!-- 微信配置 -->
<!-- 微信配置 -->
<activity
<activity
android:name=
"com.ym.
cydyj
.wxapi.WXEntryActivity"
android:name=
"com.ym.
pcdxg
.wxapi.WXEntryActivity"
android:exported=
"true"
android:exported=
"true"
android:launchMode=
"singleTop"
/>
android:launchMode=
"singleTop"
/>
<!-- WebView -->
<activity
android:name=
"com.ym.unityandroid.webview.UnityWebActivity"
android:exported=
"true"
android:screenOrientation=
"fullSensor"
>
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
<!-- WebView -->
</application>
</application>
</manifest>
</manifest>
Assets/Scripts/Controllers/GameController.cs
View file @
e9274b23
...
@@ -26,6 +26,7 @@ public class GameController : MonoBehaviour
...
@@ -26,6 +26,7 @@ public class GameController : MonoBehaviour
public
float
RedLinePosY
=>
ColliderAdapter
.
Instance
.
RedLinePosY
;
public
float
RedLinePosY
=>
ColliderAdapter
.
Instance
.
RedLinePosY
;
<<<<<<<
HEAD
/// <summary>
/// <summary>
/// 获取接下来将要掉落的音符组及所属歌曲
/// 获取接下来将要掉落的音符组及所属歌曲
...
@@ -43,28 +44,18 @@ public class GameController : MonoBehaviour
...
@@ -43,28 +44,18 @@ public class GameController : MonoBehaviour
}));
}));
}
}
=======
/// <summary>
/// <summary>
/// 获取合成奖励
/// 获取提现列表
/// 类型(1 合成提现,3大额提现)
/// </summary>
/// </summary>
/// <param name="song_id"></param>
public
void
GetWithdrawList
(
int
type
)
public
void
GetReward
()
{
{
Dictionary
<
string
,
object
>
paras
=
new
Dictionary
<
string
,
object
>();
Dictionary
<
string
,
object
>
paras
=
new
Dictionary
<
string
,
object
>();
paras
.
Add
(
"type"
,
1
);
paras
.
Add
(
"type"
,
type
);
HttpTool
.
Instance
.
_Get
(
"app/v1/watermelon/
reward"
,
paras
,
new
Action
<
Empty
Bean
>((
result
)
=>
HttpTool
.
Instance
.
_Get
(
"app/v1/watermelon/
list_wd"
,
paras
,
new
Action
<
WithDraw
Bean
>((
result
)
=>
{
{
>>>>>>>
71
cb07ae8564a188b735be49fa9ff46c44542906
}),
new
Action
<
string
,
string
>((
code
,
msg
)
=>
{
Debug
.
unityLogger
.
Log
(
"获取合成奖励 "
+
code
+
" msg "
+
msg
);
}));
}
}
}
Assets/Scripts/Main/HomeInfoControl.cs
View file @
e9274b23
...
@@ -25,11 +25,14 @@ public class HomeInfoControl : MonoBehaviour
...
@@ -25,11 +25,14 @@ public class HomeInfoControl : MonoBehaviour
#if UNITY_EDITOR
#if UNITY_EDITOR
AppConfig
.
Instance
.
InitProgect
(
true
);
AppConfig
.
Instance
.
InitProgect
(
true
);
#endif
#endif
EventCenter
.
Getinstance
().
EventTrigger
(
"RegisterPanel"
);
EventCenter
.
Getinstance
().
EventTrigger
(
"RegisterPanel"
);
<<<<<<<
HEAD
//GameController.GetInstance().GetWithdrawList(1);
//GameController.GetInstance().GetWithdrawList(1);
GameController
.
GetInstance
().
GetReward
();
GameController
.
GetInstance
().
GetReward
();
=======
GameController
.
GetInstance
().
GetWithdrawList
(
1
);
>>>>>>>
71
cb07ae8564a188b735be49fa9ff46c44542906
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment