Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
严琪
/
paysplug-in
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
af081a4c
authored
Mar 08, 2018
by
jeffrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api调整
parent
1c4ab18c
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
317 additions
and
29 deletions
+317
-29
app/build.gradle
+13
-8
app/src/main/java/com/yuqirong/listenwechatnotification/MainActivity.java
+6
-8
app/src/main/java/com/yuqirong/listenwechatnotification/askhttp/HttpLoggingInterceptor.java
+272
-0
app/src/main/java/com/yuqirong/listenwechatnotification/askhttp/UpdateApk.java
+6
-2
app/src/main/java/com/yuqirong/listenwechatnotification/function/JobAwaken.java
+11
-6
app/src/main/java/com/yuqirong/listenwechatnotification/http/HttpService.java
+2
-1
app/src/main/java/com/yuqirong/listenwechatnotification/service/WeChatNotificationListenerService.java
+1
-1
app/src/main/java/com/yuqirong/listenwechatnotification/uitl/Save2SharedPreferences.java
+4
-3
build.gradle
+2
-0
No files found.
app/build.gradle
View file @
af081a4c
...
@@ -6,32 +6,37 @@ android {
...
@@ -6,32 +6,37 @@ android {
debug
{
debug
{
keyAlias
'demo'
keyAlias
'demo'
keyPassword
'wswy1234'
keyPassword
'wswy1234'
storeFile
file
(
'
F:/gitdemo/ListenWeChatNotification/paysplug-in/app
/NotificationListener.jks'
)
storeFile
file
(
'
.
/NotificationListener.jks'
)
storePassword
'wswy1234'
storePassword
'wswy1234'
}
}
release
{
release
{
keyAlias
'demo'
keyAlias
'demo'
keyPassword
'wswy1234'
keyPassword
'wswy1234'
storeFile
file
(
'
F:/gitdemo/ListenWeChatNotification/paysplug-in/app
/NotificationListener.jks'
)
storeFile
file
(
'
.
/NotificationListener.jks'
)
storePassword
'wswy1234'
storePassword
'wswy1234'
}
}
}
}
compileSdkVersion
2
5
compileSdkVersion
2
6
buildToolsVersion
"2
5.0.0
"
buildToolsVersion
"2
6.0.2
"
defaultConfig
{
defaultConfig
{
applicationId
"com.yuqirong.listenwechatnotification"
applicationId
"com.yuqirong.listenwechatnotification"
minSdkVersion
16
minSdkVersion
16
targetSdkVersion
2
5
targetSdkVersion
2
6
versionCode
1
0
versionCode
1
1
versionName
"1.
1
"
versionName
"1.
2
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
}
buildTypes
{
buildTypes
{
release
{
release
{
minifyEnabled
false
minifyEnabled
false
signingConfig
signingConfigs
.
release
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
debug
{
signingConfig
signingConfigs
.
debug
}
}
}
}
}
...
@@ -40,7 +45,7 @@ dependencies {
...
@@ -40,7 +45,7 @@ dependencies {
androidTestCompile
(
'com.android.support.test.espresso:espresso-core:2.2.2'
,
{
androidTestCompile
(
'com.android.support.test.espresso:espresso-core:2.2.2'
,
{
exclude
group:
'com.android.support'
,
module:
'support-annotations'
exclude
group:
'com.android.support'
,
module:
'support-annotations'
})
})
compile
'com.android.support:appcompat-v7:2
5.0
.0'
compile
'com.android.support:appcompat-v7:2
6.1
.0'
testCompile
'junit:junit:4.12'
testCompile
'junit:junit:4.12'
//添加retrofit-会自动下载okhttp
//添加retrofit-会自动下载okhttp
compile
'com.squareup.retrofit2:retrofit:2.1.0'
compile
'com.squareup.retrofit2:retrofit:2.1.0'
...
...
app/src/main/java/com/yuqirong/listenwechatnotification/MainActivity.java
View file @
af081a4c
...
@@ -44,7 +44,6 @@ public class MainActivity extends ParentActivity {
...
@@ -44,7 +44,6 @@ public class MainActivity extends ParentActivity {
String
TAG
=
"MainActivity"
;
String
TAG
=
"MainActivity"
;
private
BuildUrlsFunction
functionUrls
;
private
BuildUrlsFunction
functionUrls
;
private
Save2SharedPreferences
save2SharedPreferences
;
private
AlarmManager
am
;
private
AlarmManager
am
;
private
PendingIntent
pi
;
private
PendingIntent
pi
;
...
@@ -56,7 +55,6 @@ public class MainActivity extends ParentActivity {
...
@@ -56,7 +55,6 @@ public class MainActivity extends ParentActivity {
@Override
@Override
public
void
initView
()
{
public
void
initView
()
{
functionUrls
=
new
BuildUrlsFunction
();
functionUrls
=
new
BuildUrlsFunction
();
save2SharedPreferences
=
new
Save2SharedPreferences
();
final
EditText
etText1
=
(
EditText
)
findViewById
(
R
.
id
.
et_text1
);
final
EditText
etText1
=
(
EditText
)
findViewById
(
R
.
id
.
et_text1
);
final
EditText
etText2
=
(
EditText
)
findViewById
(
R
.
id
.
et_text2
);
final
EditText
etText2
=
(
EditText
)
findViewById
(
R
.
id
.
et_text2
);
...
@@ -65,20 +63,20 @@ public class MainActivity extends ParentActivity {
...
@@ -65,20 +63,20 @@ public class MainActivity extends ParentActivity {
versionCode
=
(
TextView
)
findViewById
(
R
.
id
.
versiontext
);
versionCode
=
(
TextView
)
findViewById
(
R
.
id
.
versiontext
);
etText1
.
setText
(
s
ave2SharedPreferences
.
read
(
ALIPAYNAME
,
this
),
TextView
.
BufferType
.
NORMAL
);
etText1
.
setText
(
S
ave2SharedPreferences
.
read
(
ALIPAYNAME
,
this
),
TextView
.
BufferType
.
NORMAL
);
etText2
.
setText
(
s
ave2SharedPreferences
.
read
(
API
,
this
),
TextView
.
BufferType
.
NORMAL
);
etText2
.
setText
(
S
ave2SharedPreferences
.
read
(
API
,
this
),
TextView
.
BufferType
.
NORMAL
);
etText3
.
setText
(
s
ave2SharedPreferences
.
read
(
WECHATPAYNAME
,
this
),
TextView
.
BufferType
.
NORMAL
);
etText3
.
setText
(
S
ave2SharedPreferences
.
read
(
WECHATPAYNAME
,
this
),
TextView
.
BufferType
.
NORMAL
);
Button
btButton
=
(
Button
)
findViewById
(
R
.
id
.
bt_button
);
Button
btButton
=
(
Button
)
findViewById
(
R
.
id
.
bt_button
);
btButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
btButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
stringAliPay
=
etText1
.
getText
().
toString
();
stringAliPay
=
etText1
.
getText
().
toString
();
s
ave2SharedPreferences
.
save
(
ALIPAYNAME
,
stringAliPay
,
MainActivity
.
this
);
S
ave2SharedPreferences
.
save
(
ALIPAYNAME
,
stringAliPay
,
MainActivity
.
this
);
stringWeChatPay
=
etText3
.
getText
().
toString
();
stringWeChatPay
=
etText3
.
getText
().
toString
();
s
ave2SharedPreferences
.
save
(
WECHATPAYNAME
,
stringWeChatPay
,
MainActivity
.
this
);
S
ave2SharedPreferences
.
save
(
WECHATPAYNAME
,
stringWeChatPay
,
MainActivity
.
this
);
stringAPI
=
etText2
.
getText
().
toString
();
stringAPI
=
etText2
.
getText
().
toString
();
s
ave2SharedPreferences
.
save
(
API
,
stringAPI
,
MainActivity
.
this
);
S
ave2SharedPreferences
.
save
(
API
,
stringAPI
,
MainActivity
.
this
);
Toast
.
makeText
(
MainActivity
.
this
,
"保存成功,支付宝账号="
+
stringAliPay
+
";微信账号="
+
stringWeChatPay
+
";api="
+
stringAPI
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
MainActivity
.
this
,
"保存成功,支付宝账号="
+
stringAliPay
+
";微信账号="
+
stringWeChatPay
+
";api="
+
stringAPI
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
...
...
app/src/main/java/com/yuqirong/listenwechatnotification/askhttp/HttpLoggingInterceptor.java
0 → 100644
View file @
af081a4c
package
com
.
yuqirong
.
listenwechatnotification
.
askhttp
;
/**
* Created by Li on 2016/9/26.
*/
/*
* Copyright (C) 2015 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
android.util.Log
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.nio.charset.Charset
;
import
java.nio.charset.UnsupportedCharsetException
;
import
java.util.concurrent.TimeUnit
;
import
okhttp3.Connection
;
import
okhttp3.Headers
;
import
okhttp3.Interceptor
;
import
okhttp3.MediaType
;
import
okhttp3.Protocol
;
import
okhttp3.Request
;
import
okhttp3.RequestBody
;
import
okhttp3.Response
;
import
okhttp3.ResponseBody
;
import
okio.Buffer
;
import
okio.BufferedSource
;
/**
* 就是抄的okhttp的HttpLoggingInterceptor 但是加入了response的包体解密
*/
public
final
class
HttpLoggingInterceptor
implements
Interceptor
{
private
static
final
Charset
UTF8
=
Charset
.
forName
(
"UTF-8"
);
public
enum
Level
{
NONE
,
BASIC
,
HEADERS
,
BODY
}
public
interface
Logger
{
void
log
(
String
message
);
void
logJson
(
String
message
);
Logger
DEFAULT
=
new
Logger
()
{
@Override
public
void
log
(
String
message
)
{
Log
.
i
(
"HTTP"
,
message
);
}
@Override
public
void
logJson
(
String
message
)
{
Log
.
i
(
"HTTP"
,
message
);
}
};
}
public
HttpLoggingInterceptor
()
{
this
(
Logger
.
DEFAULT
);
}
public
HttpLoggingInterceptor
(
Logger
logger
)
{
this
.
logger
=
logger
;
}
private
final
Logger
logger
;
private
volatile
Level
level
=
Level
.
BODY
;
/**
* Change the level at which this interceptor logs.
*/
public
HttpLoggingInterceptor
setLevel
(
Level
level
)
{
if
(
level
==
null
)
{
throw
new
NullPointerException
(
"level == null. Use Level.NONE instead."
);
}
this
.
level
=
level
;
return
this
;
}
public
Level
getLevel
()
{
return
level
;
}
@Override
public
Response
intercept
(
Chain
chain
)
throws
IOException
{
Level
level
=
this
.
level
;
Request
request
=
chain
.
request
();
if
(
level
==
Level
.
NONE
)
{
return
chain
.
proceed
(
request
);
}
boolean
logBody
=
level
==
Level
.
BODY
;
boolean
logHeaders
=
logBody
||
level
==
Level
.
HEADERS
;
RequestBody
requestBody
=
request
.
body
();
boolean
hasRequestBody
=
requestBody
!=
null
;
Connection
connection
=
chain
.
connection
();
Protocol
protocol
=
connection
!=
null
?
connection
.
protocol
()
:
Protocol
.
HTTP_1_1
;
String
requestStartMessage
=
"--> "
+
request
.
method
()
+
' '
+
request
.
url
()
+
' '
+
protocol
;
if
(!
logHeaders
&&
hasRequestBody
)
{
requestStartMessage
+=
" ("
+
requestBody
.
contentLength
()
+
"-byte body)"
;
}
logger
.
log
(
requestStartMessage
);
if
(
logHeaders
)
{
if
(
hasRequestBody
)
{
// Request body headers are only present when installed as a network interceptor. Force
// them to be included (when available) so there values are known.
if
(
requestBody
.
contentType
()
!=
null
)
{
logger
.
log
(
"Content-Type: "
+
requestBody
.
contentType
());
}
if
(
requestBody
.
contentLength
()
!=
-
1
)
{
logger
.
log
(
"Content-Length: "
+
requestBody
.
contentLength
());
}
}
Headers
headers
=
request
.
headers
();
for
(
int
i
=
0
,
count
=
headers
.
size
();
i
<
count
;
i
++)
{
String
name
=
headers
.
name
(
i
);
// Skip headers from the refresh body as they are explicitly logged above.
if
(!
"Content-Type"
.
equalsIgnoreCase
(
name
)
&&
!
"Content-Length"
.
equalsIgnoreCase
(
name
))
{
logger
.
log
(
name
+
": "
+
headers
.
value
(
i
));
}
}
if
(!
logBody
||
!
hasRequestBody
)
{
logger
.
log
(
"--> END "
+
request
.
method
());
}
else
if
(
bodyEncoded
(
request
.
headers
()))
{
logger
.
log
(
"--> END "
+
request
.
method
()
+
" (encoded body omitted)"
);
}
else
{
Buffer
buffer
=
new
Buffer
();
requestBody
.
writeTo
(
buffer
);
Charset
charset
=
UTF8
;
MediaType
contentType
=
requestBody
.
contentType
();
if
(
contentType
!=
null
)
{
charset
=
contentType
.
charset
(
UTF8
);
}
logger
.
log
(
""
);
if
(
isPlaintext
(
buffer
))
{
String
strReq
=
buffer
.
readString
(
charset
);
logger
.
log
(
strReq
);
logger
.
log
(
"--> END "
+
request
.
method
()
+
" ("
+
requestBody
.
contentLength
()
+
"-byte body)"
);
}
else
{
logger
.
log
(
"--> END "
+
request
.
method
()
+
" (binary "
+
requestBody
.
contentLength
()
+
"-byte body omitted)"
);
}
}
}
long
startNs
=
System
.
nanoTime
();
Response
response
;
try
{
response
=
chain
.
proceed
(
request
);
}
catch
(
Exception
e
)
{
logger
.
log
(
"<-- HTTP FAILED: "
+
e
);
throw
e
;
}
long
tookMs
=
TimeUnit
.
NANOSECONDS
.
toMillis
(
System
.
nanoTime
()
-
startNs
);
ResponseBody
responseBody
=
response
.
body
();
long
contentLength
=
responseBody
.
contentLength
();
String
bodySize
=
contentLength
!=
-
1
?
contentLength
+
"-byte"
:
"unknown-length"
;
logger
.
log
(
"<-- "
+
response
.
code
()
+
' '
+
response
.
message
()
+
' '
+
response
.
request
().
url
()
+
" ("
+
tookMs
+
"ms"
+
(!
logHeaders
?
", "
+
bodySize
+
" body"
:
""
)
+
')'
);
if
(
logHeaders
)
{
Headers
headers
=
response
.
headers
();
for
(
int
i
=
0
,
count
=
headers
.
size
();
i
<
count
;
i
++)
{
logger
.
log
(
headers
.
name
(
i
)
+
": "
+
headers
.
value
(
i
));
}
if
(!
logBody
)
{
logger
.
log
(
"<-- END HTTP"
);
}
else
if
(
bodyEncoded
(
response
.
headers
()))
{
logger
.
log
(
"<-- END HTTP (encoded body omitted)"
);
}
else
{
BufferedSource
source
=
responseBody
.
source
();
source
.
request
(
Long
.
MAX_VALUE
);
// Buffer the entire body.
Buffer
buffer
=
source
.
buffer
();
Charset
charset
=
UTF8
;
MediaType
contentType
=
responseBody
.
contentType
();
if
(
contentType
!=
null
)
{
try
{
charset
=
contentType
.
charset
(
UTF8
);
}
catch
(
UnsupportedCharsetException
e
)
{
logger
.
log
(
""
);
logger
.
log
(
"Couldn't decode the response body; charset is likely malformed."
);
logger
.
log
(
"<-- END HTTP"
);
return
response
;
}
}
if
(!
isPlaintext
(
buffer
))
{
logger
.
log
(
""
);
logger
.
log
(
"<-- END HTTP (binary "
+
buffer
.
size
()
+
"-byte body omitted)"
);
return
response
;
}
/**
* 10K还可以接受吧
*/
if
(
contentLength
!=
0
&&
contentLength
<
1024
*
10
)
{
logger
.
log
(
""
);
String
strResp
=
buffer
.
clone
().
readString
(
charset
);
logger
.
logJson
(
strResp
);
}
else
{
logger
.
log
(
"resp too much more than 10K"
);
}
logger
.
log
(
"<-- END HTTP ("
+
buffer
.
size
()
+
"-byte body)"
);
}
}
return
response
;
}
/**
* Returns true if the body in question probably contains human readable text. Uses a small sample
* of code points to detect unicode control characters commonly used in binary file signatures.
*/
static
boolean
isPlaintext
(
Buffer
buffer
)
throws
EOFException
{
try
{
Buffer
prefix
=
new
Buffer
();
long
byteCount
=
buffer
.
size
()
<
64
?
buffer
.
size
()
:
64
;
buffer
.
copyTo
(
prefix
,
0
,
byteCount
);
for
(
int
i
=
0
;
i
<
16
;
i
++)
{
if
(
prefix
.
exhausted
())
{
break
;
}
int
codePoint
=
prefix
.
readUtf8CodePoint
();
if
(
Character
.
isISOControl
(
codePoint
)
&&
!
Character
.
isWhitespace
(
codePoint
))
{
return
false
;
}
}
return
true
;
}
catch
(
EOFException
e
)
{
return
false
;
// Truncated UTF-8 sequence.
}
}
private
boolean
bodyEncoded
(
Headers
headers
)
{
String
contentEncoding
=
headers
.
get
(
"Content-Encoding"
);
return
contentEncoding
!=
null
&&
!
contentEncoding
.
equalsIgnoreCase
(
"identity"
);
}
}
app/src/main/java/com/yuqirong/listenwechatnotification/askhttp/UpdateApk.java
View file @
af081a4c
...
@@ -7,6 +7,7 @@ import com.yuqirong.listenwechatnotification.bean.UpdateBean;
...
@@ -7,6 +7,7 @@ import com.yuqirong.listenwechatnotification.bean.UpdateBean;
import
com.yuqirong.listenwechatnotification.function.UpgradeFunction
;
import
com.yuqirong.listenwechatnotification.function.UpgradeFunction
;
import
com.yuqirong.listenwechatnotification.http.HttpPresent
;
import
com.yuqirong.listenwechatnotification.http.HttpPresent
;
import
com.yuqirong.listenwechatnotification.http.HttpService
;
import
com.yuqirong.listenwechatnotification.http.HttpService
;
import
com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences
;
import
com.yuqirong.listenwechatnotification.uitl.Utils
;
import
com.yuqirong.listenwechatnotification.uitl.Utils
;
import
retrofit2.Call
;
import
retrofit2.Call
;
...
@@ -16,6 +17,8 @@ import retrofit2.Retrofit;
...
@@ -16,6 +17,8 @@ import retrofit2.Retrofit;
import
retrofit2.converter.gson.GsonConverterFactory
;
import
retrofit2.converter.gson.GsonConverterFactory
;
import
retrofit2.converter.scalars.ScalarsConverterFactory
;
import
retrofit2.converter.scalars.ScalarsConverterFactory
;
import
static
com
.
yuqirong
.
listenwechatnotification
.
MainActivity
.
API
;
/**
/**
* Created by yanqi on 2018/2/24 0024.
* Created by yanqi on 2018/2/24 0024.
*/
*/
...
@@ -31,9 +34,10 @@ public class UpdateApk implements HttpPresent {
...
@@ -31,9 +34,10 @@ public class UpdateApk implements HttpPresent {
}
}
public
UpdateApk
(
final
Context
context
){
public
UpdateApk
(
final
Context
context
){
String
temp
=
""
+
Utils
.
getLocalVersion
(
context
);
String
temp
=
Utils
.
getLocalVersionName
(
context
);
String
url
=
Save2SharedPreferences
.
read
(
API
,
context
);
//建立retrofit对象
//建立retrofit对象
Retrofit
retrofit
=
new
Retrofit
.
Builder
().
baseUrl
(
HttpService
.
base_
url
)
Retrofit
retrofit
=
new
Retrofit
.
Builder
().
baseUrl
(
url
)
//添加返回字符串的支持--不知道返回的是什么,添加字符串支持
//添加返回字符串的支持--不知道返回的是什么,添加字符串支持
.
addConverterFactory
(
ScalarsConverterFactory
.
create
())
.
addConverterFactory
(
ScalarsConverterFactory
.
create
())
//添加GSON转换支持
//添加GSON转换支持
...
...
app/src/main/java/com/yuqirong/listenwechatnotification/function/JobAwaken.java
View file @
af081a4c
...
@@ -5,6 +5,8 @@ import android.content.Context;
...
@@ -5,6 +5,8 @@ import android.content.Context;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
static
android
.
content
.
pm
.
PackageManager
.
MATCH_ALL
;
/**
/**
* Created by yanqi on 2018/2/24 0024.
* Created by yanqi on 2018/2/24 0024.
*/
*/
...
@@ -15,23 +17,26 @@ public class JobAwaken {
...
@@ -15,23 +17,26 @@ public class JobAwaken {
}
}
public
void
awakenAPliay
(
Context
context
){
public
void
awakenAPliay
(
Context
context
){
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MAIN
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
);
//重点是加这个
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MAIN
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
);
//重点是加这个
ComponentName
cn
=
new
ComponentName
(
"com.eg.android.AlipayGphone"
,
"com.alipay.mobile.quinox.LauncherActivity"
);
ComponentName
cn
=
new
ComponentName
(
"com.eg.android.AlipayGphone"
,
"com.alipay.mobile.quinox.LauncherActivity"
);
if
(
cn
==
null
){
intent
.
setComponent
(
cn
);
if
(
context
.
getPackageManager
().
resolveActivity
(
intent
,
MATCH_ALL
)==
null
){
Toast
.
makeText
(
context
,
"未安装支付宝"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
context
,
"未安装支付宝"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
}
else
{
intent
.
setComponent
(
cn
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
}
}
public
void
awakenWeChat
(
Context
context
){
public
void
awakenWeChat
(
Context
context
){
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MAIN
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
);
//重点是加这个
Intent
intent
=
new
Intent
(
Intent
.
ACTION_MAIN
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
|
Intent
.
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
);
//重点是加这个
ComponentName
cn
=
new
ComponentName
(
"com.tencent.mm"
,
"com.tencent.mm.ui.LauncherUI"
);
ComponentName
cn
=
new
ComponentName
(
"com.tencent.mm"
,
"com.tencent.mm.ui.LauncherUI"
);
if
(
cn
==
null
){
intent
.
setComponent
(
cn
);
if
(
context
.
getPackageManager
().
resolveActivity
(
intent
,
MATCH_ALL
)==
null
){
Toast
.
makeText
(
context
,
"未安装微信"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
context
,
"未安装微信"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
}
else
{
intent
.
setComponent
(
cn
);
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
}
}
...
...
app/src/main/java/com/yuqirong/listenwechatnotification/http/HttpService.java
View file @
af081a4c
...
@@ -15,7 +15,8 @@ import retrofit2.http.Query;
...
@@ -15,7 +15,8 @@ import retrofit2.http.Query;
public
interface
HttpService
{
public
interface
HttpService
{
public
String
base_url
=
"http://test.haoyiwangluo.com/"
;
// public String base_url = "http://test.haoyiwangluo.com/";
public
String
base_url
=
"http://www.haoyiwangluo.com/"
;
@POST
(
"index/pay/notify/person_app"
)
@POST
(
"index/pay/notify/person_app"
)
Call
<
String
>
postClientMoney
(
@Field
(
"notify_text"
)
String
notify_text
,
@Field
(
"pay_to"
)
String
pay_to
,
@Field
(
"type"
)
String
type
);
Call
<
String
>
postClientMoney
(
@Field
(
"notify_text"
)
String
notify_text
,
@Field
(
"pay_to"
)
String
pay_to
,
@Field
(
"type"
)
String
type
);
...
...
app/src/main/java/com/yuqirong/listenwechatnotification/service/WeChatNotificationListenerService.java
View file @
af081a4c
...
@@ -175,7 +175,7 @@ public class WeChatNotificationListenerService extends NotificationListenerServi
...
@@ -175,7 +175,7 @@ public class WeChatNotificationListenerService extends NotificationListenerServi
.
add
(
"type"
,
paytype
)
.
add
(
"type"
,
paytype
)
.
build
();
.
build
();
Request
request
=
new
Request
.
Builder
()
Request
request
=
new
Request
.
Builder
()
.
url
(
api
)
.
url
(
api
+
"index/pay/notify/person_app"
)
.
post
(
requestBody
)
.
post
(
requestBody
)
.
build
();
.
build
();
//发送请求获取服务器数据
//发送请求获取服务器数据
...
...
app/src/main/java/com/yuqirong/listenwechatnotification/uitl/Save2SharedPreferences.java
View file @
af081a4c
...
@@ -4,6 +4,7 @@ import android.content.Context;
...
@@ -4,6 +4,7 @@ import android.content.Context;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
com.yuqirong.listenwechatnotification.MainActivity
;
import
com.yuqirong.listenwechatnotification.MainActivity
;
import
com.yuqirong.listenwechatnotification.http.HttpService
;
import
static
android
.
content
.
Context
.
MODE_PRIVATE
;
import
static
android
.
content
.
Context
.
MODE_PRIVATE
;
...
@@ -15,7 +16,7 @@ public class Save2SharedPreferences {
...
@@ -15,7 +16,7 @@ public class Save2SharedPreferences {
public
static
String
name
=
"savelistener"
;
public
static
String
name
=
"savelistener"
;
public
void
save
(
String
key
,
String
value
,
Context
context
){
public
static
void
save
(
String
key
,
String
value
,
Context
context
){
//获取一个文件名为test、权限为private的xml文件的SharedPreferences对象
//获取一个文件名为test、权限为private的xml文件的SharedPreferences对象
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
name
,
MODE_PRIVATE
);
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
name
,
MODE_PRIVATE
);
...
@@ -27,12 +28,12 @@ public class Save2SharedPreferences {
...
@@ -27,12 +28,12 @@ public class Save2SharedPreferences {
editor
.
apply
();
editor
.
apply
();
}
}
public
String
read
(
String
key
,
Context
context
){
public
static
String
read
(
String
key
,
Context
context
){
//获取一个文件名为test、权限为private的xml文件的SharedPreferences对象
//获取一个文件名为test、权限为private的xml文件的SharedPreferences对象
if
(
key
==
MainActivity
.
API
)
{
if
(
key
==
MainActivity
.
API
)
{
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
name
,
MODE_PRIVATE
);
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
name
,
MODE_PRIVATE
);
return
sharedPreferences
.
getString
(
key
,
"http://test.haoyiwangluo.com/index/pay/notify/person_app"
);
return
sharedPreferences
.
getString
(
key
,
HttpService
.
base_url
);
}
}
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
name
,
MODE_PRIVATE
);
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
name
,
MODE_PRIVATE
);
return
sharedPreferences
.
getString
(
key
,
""
);
return
sharedPreferences
.
getString
(
key
,
""
);
...
...
build.gradle
View file @
af081a4c
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
buildscript
{
buildscript
{
repositories
{
repositories
{
jcenter
()
jcenter
()
google
()
}
}
dependencies
{
dependencies
{
classpath
'com.android.tools.build:gradle:3.0.1'
classpath
'com.android.tools.build:gradle:3.0.1'
...
@@ -15,6 +16,7 @@ buildscript {
...
@@ -15,6 +16,7 @@ buildscript {
allprojects
{
allprojects
{
repositories
{
repositories
{
jcenter
()
jcenter
()
google
()
}
}
}
}
...
...
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