|
@@ -1,8 +1,21 @@
|
|
|
package com.xunao.effectdemo;
|
|
|
|
|
|
import android.app.Application;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.pm.PackageInfo;
|
|
|
+import android.content.pm.PackageManager;
|
|
|
+import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
|
|
|
+import com.uc.crashsdk.export.CrashApi;
|
|
|
+import com.umeng.analytics.MobclickAgent;
|
|
|
+import com.umeng.commonsdk.UMConfigure;
|
|
|
+import com.xunao.effectdemo.umeng.UmInitConfig;
|
|
|
+
|
|
|
+import java.security.MessageDigest;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
+import java.util.Locale;
|
|
|
+
|
|
|
import cn.jpush.android.api.JPushInterface;
|
|
|
|
|
|
/**
|
|
@@ -26,34 +39,78 @@ public class App extends Application {
|
|
|
app = this;
|
|
|
JPushInterface.setDebugMode(true);
|
|
|
JPushInterface.init(this);
|
|
|
-
|
|
|
+// getSHA1Signature(this);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化友盟SDK
|
|
|
*/
|
|
|
private void initUmengSDK() {
|
|
|
- //日志开关
|
|
|
-// UMConfigure.setLogEnabled(true);
|
|
|
- //预初始化
|
|
|
-// PushHelper.preInit(this);
|
|
|
-// //是否同意隐私政策
|
|
|
-// boolean agreed = true;
|
|
|
-// if (!agreed) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// boolean isMainProcess = UMUtils.isMainProgress(this);
|
|
|
-// if (isMainProcess) {
|
|
|
-// //启动优化:建议在子线程中执行初始化
|
|
|
-// new Thread(new Runnable() {
|
|
|
-// @Override
|
|
|
-// public void run() {
|
|
|
-// PushHelper.init(getApplicationContext());
|
|
|
-// }
|
|
|
-// }).start();
|
|
|
-// } else {
|
|
|
-// //若不是主进程(":channel"结尾的进程),直接初始化sdk,不可在子线程中执行
|
|
|
-// PushHelper.init(getApplicationContext());
|
|
|
-// }
|
|
|
+// sharedPreferencesHelper=new SharedPreferencesHelper(this,"umeng");
|
|
|
+
|
|
|
+ //设置LOG开关,默认为false
|
|
|
+ UMConfigure.setLogEnabled(true);
|
|
|
+
|
|
|
+ //友盟预初始化
|
|
|
+ UMConfigure.preInit(getApplicationContext(),"6304343088ccdf4b7e0d67bb","Umeng");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 打开app首次隐私协议授权,以及sdk初始化,判断逻辑请查看SplashTestActivity
|
|
|
+ */
|
|
|
+ //判断是否同意隐私协议,uminit为1时为已经同意,直接初始化umsdk
|
|
|
+ //友盟正式初始化
|
|
|
+ UmInitConfig umInitConfig=new UmInitConfig();
|
|
|
+ umInitConfig.UMinit(getApplicationContext());
|
|
|
+
|
|
|
+ final Bundle customInfo = new Bundle();
|
|
|
+ customInfo.putBoolean("mCallNativeDefaultHandler",true);
|
|
|
+ CrashApi.getInstance().updateCustomInfo(customInfo);
|
|
|
+
|
|
|
+ // 自动采集选择
|
|
|
+ MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
|
|
|
+
|
|
|
+ // 支持在子进程中统计自定义事件
|
|
|
+ UMConfigure.setProcessEvent(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getSHA1Signature(Context context) {
|
|
|
+ try {
|
|
|
+ PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES);
|
|
|
+
|
|
|
+ byte[] cert = info.signatures[0].toByteArray();
|
|
|
+
|
|
|
+ MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
+ byte[] publicKey = md.digest(cert);
|
|
|
+ StringBuilder hexString = new StringBuilder();
|
|
|
+ for (int i = 0; i < publicKey.length; i++) {
|
|
|
+ String appendString = Integer.toHexString(0xFF & publicKey[i])
|
|
|
+ .toUpperCase(Locale.US);
|
|
|
+ if (appendString.length() == 1)
|
|
|
+ hexString.append("0");
|
|
|
+ appendString.replaceAll(":","");
|
|
|
+ hexString.append(appendString);
|
|
|
+ hexString.append(":");
|
|
|
+ }
|
|
|
+ Log.e("MyTag","签名:"+hexString.toString());
|
|
|
+ } catch (PackageManager.NameNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (NoSuchAlgorithmException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将给定字符串中给定的区域的字符转换成小写
|
|
|
+ *
|
|
|
+ * @param str 给定字符串中
|
|
|
+ * @param beginIndex 开始索引(包括)
|
|
|
+ * @param endIndex 结束索引(不包括)
|
|
|
+ * @return 新的字符串
|
|
|
+ */
|
|
|
+ public static String toLowerCase(String str, int beginIndex, int endIndex) {
|
|
|
+ return str.replaceFirst(str.substring(beginIndex, endIndex),
|
|
|
+ str.substring(beginIndex, endIndex)
|
|
|
+ .toLowerCase(Locale.getDefault()));
|
|
|
}
|
|
|
}
|