千寻位置 v2.8.9版本的 MD5 值为:c028423c956e81d2a162977350c0ec2e
以下内容为反编译后的 AppUtil.java 源代码,内容仅作参考
package com.qx.wz.qxwz.util;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.qx.wz.logger.Logger;
import com.qx.wz.net.utils.CollectionUtil;
import com.qx.wz.qxwz.biz.showh5.WebViewActivity;
import com.qx.wz.utils.IntentUtil;
import com.qx.wz.utils.ObjectUtil;
import com.qx.wz.utils.StringUtil;
import com.qx.wz.utils.TimeCount;
import com.qx.wz.utils.router.RouterList;
import com.qx.wz.view.BadgeView;
import com.qx.wz.view.badgeview.BadgeFactory;
import com.qx.wz.view.badgeview.BadgeViewNew;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Iterator;
import java.util.List;
public final class AppUtil {
private static final String[] REQUIRED_PERMISSIONS = {"android.permission.ACCESS_COARSE_LOCATION", "android.permission.ACCESS_FINE_LOCATION"};
private static final String TAG = "AppUtil";
public static void addRedDotNum(Context context, View view, int i) {
BadgeView badgeView = new BadgeView(context);
badgeView.setTargetView(view);
badgeView.setBadgeCount(i);
}
public static void addRedDotNum(BadgeView badgeView, View view, int i) {
badgeView.setTargetView(view);
badgeView.setBadgeCount(i);
}
public static void hideRedDot(BadgeView badgeView) {
badgeView.setVisibility(8);
}
public static void createRedDot(Context context, View view) {
BadgeFactory.createDot(context).bind(view);
}
public static void createRedDot(BadgeViewNew badgeViewNew, View view) {
badgeViewNew.bind(view);
}
public static void stopSmsCount(TextView textView) {
if (textView == null || textView.getTag() == null || !(textView.getTag() instanceof TimeCount)) {
return;
}
TimeCount timeCount = (TimeCount) textView.getTag();
if (!timeCount.isFinish()) {
timeCount.finish();
}
textView.setTag(null);
}
public static void goWebView(Context context) {
Intent intent = new Intent(context, (Class<?>) WebViewActivity.class);
intent.putExtra(SessionKey.NEED_HIDE_TITLE_BAR_RIGHT_ICON, true);
intent.putExtra("url", "https://m.qxwz.com/service-agreement.html?embed=app");
IntentUtil.startActivity(context, intent);
}
public static boolean isLaunchedActivity(Context context, Class<?> cls) {
ComponentName resolveActivity = new Intent(context, cls).resolveActivity(context.getPackageManager());
if (resolveActivity != null) {
Iterator<ActivityManager.RunningTaskInfo> it = ((ActivityManager) context.getSystemService("activity")).getRunningTasks(10).iterator();
while (it.hasNext()) {
if (it.next().baseActivity.equals(resolveActivity)) {
return true;
}
}
}
return false;
}
public static boolean isAppRunning(Context context, String str) {
Iterator<ActivityManager.RunningAppProcessInfo> it = ((ActivityManager) context.getSystemService("activity")).getRunningAppProcesses().iterator();
while (it.hasNext()) {
if (it.next().processName.equals(str)) {
return true;
}
}
return false;
}
public static boolean isAppRunInFront(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
if (activityManager != null) {
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = activityManager.getRunningAppProcesses();
if (CollectionUtil.notEmpty(runningAppProcesses)) {
for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
if (ObjectUtil.nonNull(runningAppProcessInfo) && StringUtil.isNotBlank(runningAppProcessInfo.processName) && runningAppProcessInfo.processName.equals(context.getPackageName())) {
if (runningAppProcessInfo.importance != 100) {
Logger.i(context.getPackageName(), "App Run In Front" + runningAppProcessInfo.processName);
return false;
}
Logger.i(context.getPackageName(), "App Run In Background" + runningAppProcessInfo.processName);
return true;
}
}
}
}
return false;
}
public static void goToBrowser(Context context, String str) {
String uRLDecoderUrl = getURLDecoderUrl(str);
if (ObjectUtil.nonNull(context) && StringUtil.isNotBlank(uRLDecoderUrl)) {
try {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setData(Uri.parse(uRLDecoderUrl));
context.startActivity(intent);
} catch (Exception unused) {
if (goSystemBrowser(context, "com.android.browser", "com.android.browser.BrowserActivity", uRLDecoderUrl)) {
return;
}
goSystemBrowser(context, "org.chromium.webview_shell", "org.chromium.webview_shell.WebViewBrowserActivity", uRLDecoderUrl);
}
}
}
public static boolean isClassExist(Context context, String str, String str2) {
if (ObjectUtil.isNull(context) || StringUtil.isBlank(str) || StringUtil.isBlank(str2)) {
return false;
}
Intent intent = new Intent();
intent.setClassName(str, str2);
return (intent.resolveActivity(context.getPackageManager()) == null && context.getPackageManager().resolveActivity(intent, 0) == null && !CollectionUtil.notEmpty(context.getPackageManager().queryIntentActivities(intent, 0))) ? false : true;
}
public static String getURLDecoderUrl(String str) {
if (StringUtil.isBlank(str)) {
return null;
}
try {
return URLDecoder.decode(str, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return str;
}
}
public static boolean goSystemBrowser(Context context, String str, String str2, String str3) {
try {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setData(Uri.parse(str3));
if (!isClassExist(context, str, str2)) {
return false;
}
intent.setClassName(str, str2);
context.startActivity(intent);
return true;
} catch (Exception unused) {
return false;
}
}
public static boolean isAppOnForeground(Context context) {
if (ObjectUtil.isNull(context) || ObjectUtil.isNull(context.getApplicationContext())) {
return false;
}
try {
Context applicationContext = context.getApplicationContext();
ActivityManager activityManager = (ActivityManager) applicationContext.getSystemService("activity");
String packageName = applicationContext.getPackageName();
List<ActivityManager.RunningAppProcessInfo> runningAppProcesses = activityManager.getRunningAppProcesses();
if (!CollectionUtil.isEmpty(runningAppProcesses) && !StringUtil.isBlank(packageName)) {
for (ActivityManager.RunningAppProcessInfo runningAppProcessInfo : runningAppProcesses) {
if (ObjectUtil.nonNull(runningAppProcessInfo) && StringUtil.isNotBlank(runningAppProcessInfo.processName) && runningAppProcessInfo.processName.equals(packageName) && runningAppProcessInfo.importance == 100) {
return true;
}
}
return false;
}
return false;
} catch (Exception unused) {
return false;
}
}
public static boolean dial(String str) {
try {
IntentUtil.startActivity(new Intent("android.intent.action.DIAL", Uri.parse("tel:" + str)));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static boolean mailto(String str) {
try {
IntentUtil.startActivity(new Intent("android.intent.action.SENDTO", Uri.parse("mailto:" + str)));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static Bundle homeBundle() {
Bundle bundle = new Bundle();
bundle.putString(IntentKey.RN_QXMODULE, "hybridMall");
bundle.putString("router", RouterList.ROUTER_PATH_DASHBOARD_HOMEPAGE);
return bundle;
}
public static boolean checkinitialPropertiesValid(Bundle bundle) {
return ObjectUtil.nonNull(bundle) && !StringUtil.isBlank(bundle.getString("router"));
}
}