admin
2021-07-28 c0269fcfa876b9c5cf309b2006462b4d09c5ef95
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
package com.hanju.video.app.receiver;
 
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
 
import com.hanju.video.app.HanJuApplication;
import com.lcjian.library.util.common.StringUtils;
import com.hanju.video.app.ui.recommend.RecommendAdapter;
 
public class APPInstallReceiver extends BroadcastReceiver {
 
    private Context mContext;
 
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
            final String packageName = intent.getDataString().substring(8);
            mContext = context;
            int time = 0;
            if (Build.VERSION.SDK_INT >= 21) {
                time = 2000;
            }
 
            handler.postDelayed(new Runnable() {
 
                @Override
                public void run() {
                    if (packageName != null
                            && packageName
                                    .equalsIgnoreCase(RecommendAdapter.MM_PACKAGE_NAME)
                            && !StringUtils
                                    .isBlank(HanJuApplication.MMNumber)) {
 
                        if (packageName
                                .equalsIgnoreCase(RecommendAdapter.MM_PACKAGE_NAME)) {
                            Intent intent = new Intent();
                            intent.setComponent(new ComponentName(
                                    RecommendAdapter.MM_PACKAGE_NAME,
                                    RecommendAdapter.MM_CLASS_NAME));
                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            intent.setAction("com.memezhibo.android.exportedAction");// 么么直播action名
                            intent.putExtra("room_id", Long
                                    .parseLong(HanJuApplication.MMNumber));
 
                            try {
                                mContext.startActivity(intent);
                            } catch (ActivityNotFoundException e) {
                            }
 
                        }
 
                    }
                }
            }, time);
        }
    }
 
    Handler handler = new Handler() {
        public void handleMessage(android.os.Message msg) {
 
        }
    };
}