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) {
|
|
}
|
};
|
}
|