Commit fe95833b by 严琪

优化支付宝打开功能和界面优化

parent 01adbb59
...@@ -74,8 +74,10 @@ ...@@ -74,8 +74,10 @@
<!--android:resource="@xml/accessibility_service_config" />--> <!--android:resource="@xml/accessibility_service_config" />-->
<!--</service>--> <!--</service>-->
<receiver android:name=".broadcastReceiver.MyAwakenReceiver"> <receiver android:name=".broadcastReceiver.MyAwakenReceiver"
>
<intent-filter> <intent-filter>
<action android:name="APliayAwaken" /> <action android:name="APliayAwaken" />
</intent-filter> </intent-filter>
</receiver> </receiver>
......
...@@ -18,9 +18,7 @@ import android.widget.Toast; ...@@ -18,9 +18,7 @@ import android.widget.Toast;
import com.yuqirong.listenwechatnotification.askhttp.UpdateApk; import com.yuqirong.listenwechatnotification.askhttp.UpdateApk;
import com.yuqirong.listenwechatnotification.bean.ImageBean; import com.yuqirong.listenwechatnotification.bean.ImageBean;
import com.yuqirong.listenwechatnotification.function.BuildNotification;
import com.yuqirong.listenwechatnotification.function.BuildUrlsFunction; import com.yuqirong.listenwechatnotification.function.BuildUrlsFunction;
import com.yuqirong.listenwechatnotification.function.QRCodeFunction;
import com.yuqirong.listenwechatnotification.service.WeChatNotificationListenerService; import com.yuqirong.listenwechatnotification.service.WeChatNotificationListenerService;
import com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences; import com.yuqirong.listenwechatnotification.uitl.Save2SharedPreferences;
import com.yuqirong.listenwechatnotification.uitl.Utils; import com.yuqirong.listenwechatnotification.uitl.Utils;
...@@ -47,6 +45,8 @@ public class MainActivity extends ParentActivity { ...@@ -47,6 +45,8 @@ public class MainActivity extends ParentActivity {
private BuildUrlsFunction functionUrls; private BuildUrlsFunction functionUrls;
private Save2SharedPreferences save2SharedPreferences; private Save2SharedPreferences save2SharedPreferences;
private AlarmManager am;
private PendingIntent pi;
@Override @Override
public void setOnContentLayoutId(int id) { public void setOnContentLayoutId(int id) {
...@@ -92,10 +92,10 @@ public class MainActivity extends ParentActivity { ...@@ -92,10 +92,10 @@ public class MainActivity extends ParentActivity {
} }
}); });
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
String code = "当前版本号:"+Utils.getLocalVersion(this)+""; String code = "当前版本号:"+Utils.getLocalVersionName(this)+"";
versionCode.setText(code); versionCode.setText(code);
checkNotificationPermission(); checkNotificationPermission();
// awakenUpFucntion(); awakenUpFucntion();
} }
...@@ -159,21 +159,24 @@ private void checkNotificationPermission() { ...@@ -159,21 +159,24 @@ private void checkNotificationPermission() {
* 呼叫支付宝 * 呼叫支付宝
*/ */
private void awakenUpFucntion(){ private void awakenUpFucntion(){
//创建Intent对象,action为APliayAwaken,附加信息为字符串“支付宝起来吧” //创建Intent对象,action为APliayAwaken,附加信息为字符串“支付宝起来吧”
Intent intent = new Intent("APliayAwaken"); Intent intent = new Intent("APliayAwaken");
intent.putExtra("msg","你该打酱油了"); intent.putExtra("msg","你该打酱油了");
// ComponentName cn = new ComponentName(getPackageName(), MyAwakenReceiver.class.get());
// intent.setComponent(cn);
//定义一个PendingIntent对象,PendingIntent.getBroadcast包含了sendBroadcast的动作。 //定义一个PendingIntent对象,PendingIntent.getBroadcast包含了sendBroadcast的动作。
//也就是发送了action 为"ELITOR_CLOCK"的intent //也就是发送了action 为"ELITOR_CLOCK"的intent
PendingIntent pi = PendingIntent.getBroadcast(this,0,intent,0); pi = PendingIntent.getBroadcast(this,0,intent,0);
//AlarmManager对象,注意这里并不是new一个对象,Alarmmanager为系统级服务 //AlarmManager对象,注意这里并不是new一个对象,Alarmmanager为系统级服务
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE); am = (AlarmManager)getSystemService(ALARM_SERVICE);
//设置闹钟从当前时间开始,每隔5s执行一次PendingIntent对象pi,注意第一个参数与第二个参数的关系 //设置闹钟从当前时间开始,每隔5s执行一次PendingIntent对象pi,注意第一个参数与第二个参数的关系
// 5秒后通过PendingIntent pi对象发送广播 // 5秒后通过PendingIntent pi对象发送广播
am.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(),1000*60*60,pi); am.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis(),5000*60*60,pi);
} }
@Override @Override
...@@ -199,4 +202,10 @@ private void checkNotificationPermission() { ...@@ -199,4 +202,10 @@ private void checkNotificationPermission() {
Log.d(TAG, "Event: "+bean.getUrl()); Log.d(TAG, "Event: "+bean.getUrl());
} }
@Override
protected void onDestroy() {
super.onDestroy();
am.cancel(pi);
}
} }
...@@ -30,6 +30,8 @@ public class ParentActivity extends AppCompatActivity { ...@@ -30,6 +30,8 @@ public class ParentActivity extends AppCompatActivity {
setContentView(id); setContentView(id);
} }
public void initView(){ public void initView(){
} }
......
...@@ -26,14 +26,15 @@ public class MyAwakenReceiver extends BroadcastReceiver { ...@@ -26,14 +26,15 @@ public class MyAwakenReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
JobAwaken jobAwaken = new JobAwaken();
jobAwaken.awakenAPliay(context); if (!isServiceExisted(context,"com.alipay.pushsdk.push.NotificationService")) {
// if (!isServiceExisted(context,"com.eg.android.AlipayGphone")) { JobAwaken jobAwaken = new JobAwaken();
// JobAwaken jobAwaken = new JobAwaken(); jobAwaken.awakenAPliay(context);
// jobAwaken.awakenAPliay(context); }else{
// }else{ Log.d(TAG, "不需要开启 ");
// Log.d(TAG, "onReceive:进程存在 "); }
// }
abortBroadcast();
} }
public static boolean isServiceExisted(Context context, String className) { public static boolean isServiceExisted(Context context, String className) {
...@@ -45,7 +46,8 @@ public class MyAwakenReceiver extends BroadcastReceiver { ...@@ -45,7 +46,8 @@ public class MyAwakenReceiver extends BroadcastReceiver {
for(int i = 0; i < serviceList.size(); i++) { for(int i = 0; i < serviceList.size(); i++) {
ActivityManager.RunningServiceInfo serviceInfo = serviceList.get(i); ActivityManager.RunningServiceInfo serviceInfo = serviceList.get(i);
ComponentName serviceName = serviceInfo.service; ComponentName serviceName = serviceInfo.service;
if(serviceName.getClassName().equals(className)) { if(serviceName.getClassName().toString().contains(className)) {
Log.d(TAG, "onReceive:进程存在 ");
return true; return true;
} }
} }
......
...@@ -24,4 +24,18 @@ public class Utils { ...@@ -24,4 +24,18 @@ public class Utils {
} }
return localVersion; return localVersion;
} }
public static String getLocalVersionName(Context ctx) {
String localVersion = "";
try {
PackageInfo packageInfo = ctx.getApplicationContext()
.getPackageManager()
.getPackageInfo(ctx.getPackageName(), 0);
localVersion = packageInfo.versionName;
Log.d("TAG", "本软件的版本名。。" + localVersion);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return localVersion;
}
} }
...@@ -12,13 +12,18 @@ ...@@ -12,13 +12,18 @@
android:orientation="vertical" android:orientation="vertical"
> >
<ScrollView <android.support.v4.widget.NestedScrollView
android:overScrollMode="never"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
>
<LinearLayout <LinearLayout
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -31,6 +36,8 @@ ...@@ -31,6 +36,8 @@
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<EditText <EditText
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_below="@id/text1" android:layout_below="@id/text1"
android:id="@+id/et_text1" android:id="@+id/et_text1"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -51,6 +58,8 @@ ...@@ -51,6 +58,8 @@
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<EditText <EditText
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_below="@id/text3" android:layout_below="@id/text3"
android:id="@+id/et_text3" android:id="@+id/et_text3"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -71,6 +80,8 @@ ...@@ -71,6 +80,8 @@
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
<EditText <EditText
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_below="@id/text2" android:layout_below="@id/text2"
android:id="@+id/et_text2" android:id="@+id/et_text2"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -103,6 +114,7 @@ ...@@ -103,6 +114,7 @@
android:layout_height="20dp" android:layout_height="20dp"
android:text="11111"/> android:text="11111"/>
</LinearLayout> </LinearLayout>
</ScrollView>
</android.support.v4.widget.NestedScrollView>
</LinearLayout> </LinearLayout>
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