老项目突然收不到推送,也不知道什么情况
集成官网最新版本后也还是收不到,重写个demo又可以
考虑到项目中第三方库比较多,可能是冲突,遂在Application中作如下调整得以解决
@Override
public void onCreate() {
super.onCreate();
int pid = android.os.Process.myPid();
String processAppName = getAppName(pid);
DBLDebug.e("JpushDemo", "Hello bichi=>"+processAppName);
if (processAppName == null ||!processAppName.equalsIgnoreCase(this.getPackageName())) {
DBLDebug.e("JpushDemo", "enter the service process!=>"+processAppName);
// 则此application::onCreate 是被service 调用的,直接返回
return;
}
initOther();//其他SDK的初始化操作
}
private String getAppName(int pID) {
String processName = null;
ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List l = am.getRunningAppProcesses();
Iterator i = l.iterator();
PackageManager pm = this.getPackageManager();
while (i.hasNext()) {
ActivityManager.RunningAppProcessInfo info = (ActivityManager.RunningAppProcessInfo) (i.next());
try {
if (info.pid == pID) {
processName = info.processName;
return processName;
}
} catch (Exception e) {
Log.d("Process", "Error>> :"+ e.toString());
}
}
return processName;
}
网友评论