wjc
2025-04-11 1a08f52ec36e3b71204a23a8813fe50f1748b277
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.hdl.photovoltaic.uni;
 
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.SystemClock;
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 java.lang.ref.WeakReference;
 
import io.dcloud.feature.sdk.Interface.IDCUniMPAppSplashView;
 
public class BSplashView implements IDCUniMPAppSplashView {
    View splashView;
 
    @Override
    public View getSplashView(Context context, String appid, String s1, String s2) {
        // 在Activity中,可以直接使用this获取LayoutInflater
        LayoutInflater inflater = LayoutInflater.from(context);
        // 通过inflate方法将布局文件转换为View对象
        splashView = inflater.inflate(R.layout.activity_b_splash, null);
        //设置导航条背景颜色
        Activity activity = (Activity) context;
        activity.getWindow().setNavigationBarColor(HDLApp.getInstance().getColor(R.color.text_FF000000));
        //只能通过这种方式调用
//        Intent intent = new Intent();
//        intent.setPackage("com.hdl.photovoltaic");
//        intent.setAction("UniappService.ACTION");
//        context.bindService(intent, stringservice, Context.BIND_AUTO_CREATE);
 
        return splashView;
    }
 
 
    static ServiceConnection stringservice = new ServiceConnection() {
        private WeakReference<Context> contextWeakReference;
 
        @Override
        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            IUniappAidlInterface iUniappAidlInterface = IUniappAidlInterface.Stub.asInterface(iBinder);
            try {
                iUniappAidlInterface.sendMsg("建立连接");
            } catch (Exception e) {
            }
        }
 
        @Override
        public void onServiceDisconnected(ComponentName componentName) {
            Log.i("BSplashView", "连接已断开");
            Context context = contextWeakReference.get();
            ProcessManagerUtils.killAllProcess(contextWeakReference.get());
        }
 
        public void setContextWeakReference(WeakReference<Context> contextWeakReference) {
            this.contextWeakReference = contextWeakReference;
        }
    };
 
    @Override
    public void onCloseSplash(ViewGroup rootView) {
        if (rootView != null)
            rootView.removeView(splashView);
    }
}