| | |
| | | package com.hdl.photovoltaic.uni;
|
| | |
|
| | | import android.app.Activity;
|
| | | import android.app.ActivityManager;
|
| | | import android.content.ComponentName;
|
| | | import android.content.Context;
|
| | | import android.content.Intent;
|
| | | import android.content.ServiceConnection;
|
| | | import android.os.Build;
|
| | | import android.os.IBinder;
|
| | | import android.util.Log;
|
| | | import android.view.LayoutInflater;
|
| | | import android.view.View;
|
| | | import android.view.ViewGroup;
|
| | |
|
| | | import com.hdl.photovoltaic.HDLApp;
|
| | | import com.hdl.photovoltaic.IUniappAidlInterface;
|
| | | import com.hdl.photovoltaic.R;
|
| | | import com.hdl.photovoltaic.config.UserConfigManage;
|
| | | import com.hdl.photovoltaic.utils.ProcessManagerUtils;
|
| | | import com.hdl.photovoltaic.utils.ServiceUtils;
|
| | |
|
| | | import java.lang.ref.WeakReference;
|
| | | import java.util.List;
|
| | |
|
| | | import io.dcloud.feature.sdk.Interface.IDCUniMPAppSplashView;
|
| | |
|
| | |
| | | // 在Activity中,可以直接使用this获取LayoutInflater
|
| | | LayoutInflater inflater = LayoutInflater.from(context);
|
| | | // 通过inflate方法将布局文件转换为View对象
|
| | | splashView = inflater.inflate(R.layout.activity_c_splash, null);
|
| | | splashView = inflater.inflate(R.layout.activity_b_splash, null);
|
| | | //设置导航条背景颜色
|
| | | Activity activity = (Activity) context;
|
| | | activity.getWindow().setNavigationBarColor(HDLApp.getInstance().getColor(R.color.text_FF1C1C1E));
|
| | | try {
|
| | | // if (!UserConfigManage.getInstance().isBAccount()) {
|
| | | if (!ServiceUtils.isServiceRunning(context, MyForegroundService.class)) {
|
| | | // 启动前台服务
|
| | | Intent serviceIntent = new Intent(context, MyForegroundService.class);
|
| | | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
| | | context.startForegroundService(serviceIntent);
|
| | | } else {
|
| | | context.startService(serviceIntent);
|
| | | }
|
| | | }
|
| | | // }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return splashView;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 关闭当前应用进程
|
| | | *
|
| | | * @param context
|
| | | */
|
| | | public void killProcessByPackName(Context context) {
|
| | | if (context == null) {
|
| | | return;
|
| | | }
|
| | | final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
| | | List<ActivityManager.RunningAppProcessInfo> procList = am.getRunningAppProcesses();
|
| | | for (ActivityManager.RunningAppProcessInfo proc : procList) {
|
| | | if (proc.processName != null && proc.processName.equals(context.getPackageName())) {
|
| | | android.os.Process.killProcess(proc.pid);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | if (rootView != null)
|
| | | rootView.removeView(splashView);
|
| | | }
|
| | |
|
| | |
|
| | | }
|