Commit 8aba7d5c by 严琪

新建项目

parents
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
</list>
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/ListenWeChatNotification.iml" filepath="$PROJECT_DIR$/ListenWeChatNotification.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.yuqirong.listenwechatnotification"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
testCompile 'junit:junit:4.12'
//添加retrofit-会自动下载okhttp
compile 'com.squareup.retrofit2:retrofit:2.1.0'
//添加retrofit gson转换会自动下载gson
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//添加返回的字符串支付
compile 'com.squareup.retrofit2:converter-scalars:2.1.0'
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\Android\SDK\adt-bundle-windows-x86_64-20140702\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-release.apk","properties":{"packageId":"com.yuqirong.listenwechatnotification","split":"","minSdkVersion":"16"}}]
\ No newline at end of file
package com.yuqirong.listenwechatnotification;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.yuqirong.listenwechatnotification", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yuqirong.listenwechatnotification">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:supportsRtl="true"
android:name=".MyApplication"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="com.yuqirong.listenwechatnotification.WeChatNotificationListenerService"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
<service
android:name="com.yuqirong.listenwechatnotification.WeChatAccessibilityService"
android:label="@string/app_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessible_service_config" />
</service>
</application>
</manifest>
\ No newline at end of file
package com.yuqirong.listenwechatnotification;
import android.app.NotificationManager;
import android.content.Context;
import android.support.v7.app.NotificationCompat;
/**
* Created by yanqi on 2018/2/22 0022.
*/
public class BuildNotification {
public NotificationManager mNotifyManager;
public Context mContext;
public BuildNotification(Context context) {
this.mContext = context;
this.mNotifyManager = (NotificationManager)context.getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
}
public void listenSuccess(String mString){
//实例化NotificationCompat.Builde并设置相关属性
NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this.mContext)
//设置小图标
.setSmallIcon(R.mipmap.ic_launcher)
//设置通知标题
.setContentTitle("接受成功")
//设置通知内容
.setContentText(mString);
//设置通知时间,默认为系统发出通知的时间,通常不用设置
//.setWhen(System.currentTimeMillis());
//通过builder.build()方法生成Notification对象,并发送通知,id=1
this.mNotifyManager.notify(1, builder.build());
}
public void postSuccessOrFaild(String mString){
//实例化NotificationCompat.Builde并设置相关属性
NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this.mContext)
//设置小图标
.setSmallIcon(R.mipmap.ic_launcher)
//设置通知标题
.setContentTitle("发送反馈")
//设置通知内容
.setContentText(mString);
//设置通知时间,默认为系统发出通知的时间,通常不用设置
//.setWhen(System.currentTimeMillis());
//通过builder.build()方法生成Notification对象,并发送通知,id=1
this.mNotifyManager.notify(2, builder.build());
}
}
package com.yuqirong.listenwechatnotification;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.yuqirong.listenwechatnotification.askhttp.GetMoney;
import java.io.IOException;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class MainActivity extends AppCompatActivity {
private String string1;
private String string2;
public static String ALIPAYNAME = "key1";
public static String API = "key2";
private Save2SharedPreferences save2SharedPreferences;
private BuildNotification mBuildNotification;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
save2SharedPreferences = new Save2SharedPreferences();
final EditText etText1 = (EditText) findViewById(R.id.et_text1);
final EditText etText2 = (EditText) findViewById(R.id.et_text2);
etText1.setText(save2SharedPreferences.read(ALIPAYNAME,this),TextView.BufferType.NORMAL);
etText2.setText(save2SharedPreferences.read(API,this),TextView.BufferType.NORMAL);
Button btButton = (Button) findViewById(R.id.bt_button);
btButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
string1 = etText1.getText().toString();
save2SharedPreferences.save(ALIPAYNAME,string1,MainActivity.this);
string2 = etText2.getText().toString();
save2SharedPreferences.save(API,string2,MainActivity.this);
Toast.makeText(MainActivity.this,"保存成功,支付宝账号="+ string1 +";api="+ string2,Toast.LENGTH_SHORT).show();
}
});
checkNotificationPermission();
}
// private void sendRequestWithOkHttp() {
// //开启线程来发起网络请求
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
//
// OkHttpClient client = new OkHttpClient();
// RequestBody requestBody = new FormBody.Builder()
// .add("notify_text","")
// .add("pay_to","")
// .add("type","alipay")
// .build();
// Request request = new Request.Builder()
// .url("")
// .post(requestBody)
// .build();
// //发送请求获取服务器数据
// Response response = client.newCall(request).execute();
// String responseData = response.body().string();
// showResponse(responseData);
//
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }).start();
//
// }
//
// private void showResponse( final String response ) {
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// //在这里进行UI操作,将结果显示到界面上
//// responseText.setText(response);
// }
// });
//
// }
private void checkNotificationPermission() {
boolean enable = false;
String packageName = getPackageName();
String flat = Settings.Secure.getString(getContentResolver(), "enabled_notification_listeners");
if (flat != null) {
enable = flat.contains(packageName);
}
if (!enable) {
try {
startService(new Intent(MainActivity.this, WeChatNotificationListenerService.class));//启动服务
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
startActivity(intent);
} catch (ActivityNotFoundException e) {
try {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName cn = new ComponentName("com.android.settings", "com.android.settings.Settings$NotificationAccessSettingsActivity");
intent.setComponent(cn);
intent.putExtra(":settings:show_fragment", "NotificationAccessSettings");
startActivity(intent);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
@Override
protected void onResume() {
// toggleNotificationListenerService();
// String alipay = save2SharedPreferences.read(MainActivity.ALIPAYNAME,getApplicationContext());
// String api = save2SharedPreferences.read(MainActivity.API,getApplicationContext());
// GetMoney getMoney = new GetMoney();
// getMoney.doGetMoney("111",alipay,api,this);
super.onResume();
}
private void toggleNotificationListenerService() {
PackageManager pm;
pm = getPackageManager();
pm.setComponentEnabledSetting(new ComponentName(this, WeChatNotificationListenerService.class),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
pm.setComponentEnabledSetting(new ComponentName(this, WeChatNotificationListenerService.class),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
}
package com.yuqirong.listenwechatnotification;
import android.app.Application;
/**
* Created by yanqi on 2018/2/22 0022.
*/
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
}
}
package com.yuqirong.listenwechatnotification;
import android.content.Context;
import android.content.SharedPreferences;
import static android.content.Context.MODE_PRIVATE;
/**
* Created by yanqi on 2018/2/11 0011.
*/
public class Save2SharedPreferences {
public static String name = "savelistener";
public void save(String key, String value, Context context){
//获取一个文件名为test、权限为private的xml文件的SharedPreferences对象
SharedPreferences sharedPreferences =context.getSharedPreferences(name, MODE_PRIVATE);
//得到SharedPreferences.Editor对象,并保存数据到该对象中
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key,value);
//保存key-value对到文件中
editor.commit();
}
public String read(String key, Context context){
//获取一个文件名为test、权限为private的xml文件的SharedPreferences对象
if (key == MainActivity.API) {
SharedPreferences sharedPreferences =context.getSharedPreferences(name, MODE_PRIVATE);
return sharedPreferences.getString(key,"http://test.haoyiwangluo.com/index/pay/notify/person_app");
}
SharedPreferences sharedPreferences =context.getSharedPreferences(name, MODE_PRIVATE);
return sharedPreferences.getString(key,"");
}
}
package com.yuqirong.listenwechatnotification;
import android.accessibilityservice.AccessibilityService;
import android.app.Notification;
import android.app.PendingIntent;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.accessibility.AccessibilityEvent;
import android.widget.RemoteViews;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Anyway on 2017/2/11.
*/
public class WeChatAccessibilityService extends AccessibilityService {
@Override
public void onCreate() {
android.os.Debug.waitForDebugger();
super.onCreate();
}
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if (Build.VERSION.SDK_INT < 18) {
Notification notification = (Notification) event.getParcelableData();
List<String> textList = getText(notification);
if (textList != null && textList.size() > 0) {
for (String text : textList) {
if (!TextUtils.isEmpty(text) &&
text.contains("[微信红包]")) {
final PendingIntent pendingIntent = notification.contentIntent;
try {
if (pendingIntent != null) {
pendingIntent.send();
}
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
break;
}
}
}
}
@Override
public void onInterrupt() {
}
public List<String> getText(Notification notification) {
if (null == notification) {
return null;
}
RemoteViews views = notification.bigContentView;
if (views == null) {
views = notification.contentView;
}
if (views == null) {
return null;
}
// Use reflection to examine the m_actions member of the given RemoteViews object.
// It's not pretty, but it works.
List<String> text = new ArrayList<>();
try {
Field field = views.getClass().getDeclaredField("mActions");
field.setAccessible(true);
@SuppressWarnings("unchecked")
ArrayList<Parcelable> actions = (ArrayList<Parcelable>) field.get(views);
// Find the setText() and setTime() reflection actions
for (Parcelable p : actions) {
Parcel parcel = Parcel.obtain();
p.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
// The tag tells which type of action it is (2 is ReflectionAction, from the source)
int tag = parcel.readInt();
if (tag != 2) continue;
// View ID
parcel.readInt();
String methodName = parcel.readString();
if (null == methodName) {
continue;
} else if (methodName.equals("setText")) {
// Parameter type (10 = Character Sequence)
parcel.readInt();
// Store the actual string
String t = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel).toString().trim();
text.add(t);
}
parcel.recycle();
}
} catch (Exception e) {
e.printStackTrace();
}
return text;
}
}
package com.yuqirong.listenwechatnotification;
import android.annotation.TargetApi;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
import android.util.Log;
import android.widget.RemoteViews;
import com.yuqirong.listenwechatnotification.askhttp.GetMoney;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
/**
* Created by Anyway on 2017/2/10.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public class WeChatNotificationListenerService extends NotificationListenerService {
private String ticker;
private Save2SharedPreferences save2SharedPreferences;
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_STICKY;
}
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
Log.i("xiaolong", "open" + "-----" + sbn.getPackageName());
Log.i("xiaolong", "open" + "------" + sbn.getNotification().tickerText);
save2SharedPreferences = new Save2SharedPreferences();
String alipay = save2SharedPreferences.read(MainActivity.ALIPAYNAME,getApplicationContext());
String api = save2SharedPreferences.read(MainActivity.API,getApplicationContext());
Log.i("xiaolong", "open" + "-----" + alipay);
Log.i("xiaolong", "open" + "------" + api);
BuildNotification mBuildNotification = new BuildNotification(getApplicationContext());
if(sbn.getNotification().tickerText !="") {
ticker =sbn.getNotification().tickerText.toString();
mBuildNotification.listenSuccess(ticker);
}
sendRequestWithOkHttp();
// 如果该通知的包名不是微信,那么 pass 掉
if (!"com.tencent.mm".equals(sbn.getPackageName())) {
return;
}
Notification notification = sbn.getNotification();
if (notification == null) {
return;
}
PendingIntent pendingIntent = null;
// 当 API > 18 时,使用 extras 获取通知的详细信息
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Bundle extras = notification.extras;
if (extras != null) {
// 获取通知标题
String title = extras.getString(Notification.EXTRA_TITLE, "");
// 获取通知内容
String content = extras.getString(Notification.EXTRA_TEXT, "");
if (!TextUtils.isEmpty(content) && content.contains("[微信红包]")) {
pendingIntent = notification.contentIntent;
}
}
} else {
// 当 API = 18 时,利用反射获取内容字段
List<String> textList = getText(notification);
if (textList != null && textList.size() > 0) {
for (String text : textList) {
if (!TextUtils.isEmpty(text) && text.contains("[微信红包]")) {
pendingIntent = notification.contentIntent;
break;
}
}
}
}
// send pendingIntent to open wechat
try {
if (pendingIntent != null) {
pendingIntent.send();
}
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
}
}
private void sendRequestWithOkHttp() {
//开启线程来发起网络请求
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// OkHttpClient client = new OkHttpClient();
// String alipay = save2SharedPreferences.read(MainActivity.ALIPAYNAME,getApplicationContext());
// String api = save2SharedPreferences.read(MainActivity.API,getApplicationContext());
//
// RequestBody requestBody = new FormBody.Builder()
// .add("notify_text",ticker)
// .add("pay_to",alipay)
// .add("type","alipay")
// .build();
// Request request = new Request.Builder()
// .url(api)
// .post(requestBody)
// .build();
// //发送请求获取服务器数据
// Response response = client.newCall(request).execute();
// String responseData = response.body().string();
// System.out.println("发送成功"+responseData);
//// BuildNotification mBuildNotification = new BuildNotification(getApplicationContext());
//// mBuildNotification.postSuccessOrFaild(responseData);
//
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }).start();
String alipay = save2SharedPreferences.read(MainActivity.ALIPAYNAME,getApplicationContext());
String api = save2SharedPreferences.read(MainActivity.API,getApplicationContext());
GetMoney getMoney = new GetMoney();
getMoney.doGetMoney(ticker,alipay,api,getApplicationContext());
return;
}
@Override
public void onNotificationRemoved(StatusBarNotification sbn) {
super.onNotificationRemoved(sbn);
}
public List<String> getText(Notification notification) {
if (null == notification) {
return null;
}
RemoteViews views = notification.bigContentView;
if (views == null) {
views = notification.contentView;
}
if (views == null) {
return null;
}
// Use reflection to examine the m_actions member of the given RemoteViews object.
// It's not pretty, but it works.
List<String> text = new ArrayList<>();
try {
Field field = views.getClass().getDeclaredField("mActions");
field.setAccessible(true);
@SuppressWarnings("unchecked")
ArrayList<Parcelable> actions = (ArrayList<Parcelable>) field.get(views);
// Find the setText() and setTime() reflection actions
for (Parcelable p : actions) {
Parcel parcel = Parcel.obtain();
p.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
// The tag tells which type of action it is (2 is ReflectionAction, from the source)
int tag = parcel.readInt();
if (tag != 2) continue;
// View ID
parcel.readInt();
String methodName = parcel.readString();
if (null == methodName) {
continue;
} else if (methodName.equals("setText")) {
// Parameter type (10 = Character Sequence)
parcel.readInt();
// Store the actual string
String t = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel).toString().trim();
text.add(t);
}
parcel.recycle();
}
} catch (Exception e) {
e.printStackTrace();
}
return text;
}
}
package com.yuqirong.listenwechatnotification.askhttp;
import android.content.Context;
import android.util.Log;
import com.yuqirong.listenwechatnotification.BuildNotification;
import com.yuqirong.listenwechatnotification.MyApplication;
import com.yuqirong.listenwechatnotification.http.HttpPresent;
import com.yuqirong.listenwechatnotification.http.HttpService;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;
import static android.content.ContentValues.TAG;
/**
* Created by yanqi on 2018/2/22 0022.
*/
public class GetMoney implements HttpPresent {
public GetMoney() {
}
public void doGetMoney(String notify_text, String pay_to, String type, final Context context){
//建立retrofit对象
Retrofit retrofit = new Retrofit.Builder().baseUrl(HttpService.base_url)
//添加返回字符串的支持--不知道返回的是什么,添加字符串支持
.addConverterFactory(ScalarsConverterFactory.create())
//添加GSON转换支持
.addConverterFactory(GsonConverterFactory.create())
.build();
//获取接口
HttpService service = retrofit.create(HttpService.class);
//调用方法-返回 回调更换为对象
Call<String> call = service.postClientMoney(notify_text,pay_to,type);
//异步调用
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
;
BuildNotification mBuildNotification = new BuildNotification(context);
if(response.body()!="") {
mBuildNotification.postSuccessOrFaild(response.body());
}
Log.d(TAG, "onResponse: "+response.body());
success();
}
@Override
public void onFailure(Call<String> call, Throwable t) {
failed();
}
});
}
@Override
public String success() {
return null;
}
@Override
public String failed() {
return null;
}
}
package com.yuqirong.listenwechatnotification.http;
/**
* Created by yanqi on 2018/2/22 0022.
*/
public interface HttpPresent {
public String success();
public String failed();
}
package com.yuqirong.listenwechatnotification.http;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
/**
* Created by yanqi on 2018/2/22 0022.
*/
public interface HttpService {
public String base_url = "http://test.haoyiwangluo.com/index/";
@GET("pay/notify/person_app")
Call<String> postClientMoney(@Query("notify_text") String notify_text, @Query("pay_to") String pay_to, @Query("type") String type);
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.yuqirong.listenwechatnotification.MainActivity"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/text1"
android:text="支付宝帐号:"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_below="@id/text1"
android:id="@+id/et_text1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:maxLines="2"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp">
<TextView
android:id="@+id/text2"
android:text="api:"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_below="@id/text2"
android:id="@+id/et_text2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:maxLines="4"
/>
</RelativeLayout>
<Button
android:id="@+id/bt_button"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="保存"
/>
</LinearLayout>
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>
<resources>
<string name="app_name">支付宝监听app</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeNotificationStateChanged"
android:accessibilityFeedbackType="feedbackAllMask"
android:accessibilityFlags="flagIncludeNotImportantViews"
android:canRetrieveWindowContent="true"
android:description="@string/app_name"
android:notificationTimeout="100"
android:packageNames="com.tencent.mm" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config>
<trust-anchors>
<certificates src="system"/>
<certificates src="user"/>
</trust-anchors>
</base-config>
</network-security-config>
\ No newline at end of file
package com.yuqirong.listenwechatnotification;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Fri Feb 09 21:30:45 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
include ':app'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment