cn.bmob.v3.Bmob Java Examples

The following examples show how to use cn.bmob.v3.Bmob. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicActivity.java    From ToDoList with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bmob.initialize(getApplication(), APP_ID);
    //注册网络状态监听广播
    networkReceiver = new NetworkReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
    filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
    filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    registerReceiver(networkReceiver, filter);
    isRegistered = true;

    Toasty.Config.getInstance()
            .setSuccessColor(getResources().getColor(R.color.toastSuccess))
            .setErrorColor(getResources().getColor(R.color.toastError))
            .setInfoColor(getResources().getColor(R.color.toastInfo))
            .apply();

}
 
Example #2
Source File: BaseActivity.java    From VSigner with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	 // 初始化 Bmob SDK
       // 使用时请将第二个参数Application ID替换成你在Bmob服务器端创建的Application ID
	Bmob.initialize(this, Constants.BmobAPPID);
	
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	//获取当前屏幕宽高
	DisplayMetrics metric = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics(metric);
	mScreenWidth = metric.widthPixels;
	mScreenHeight = metric.heightPixels;
	
	// 初始化数据
	mContext = this;
	mBmobInstallation = BmobInstallation.getCurrentInstallation(this);
	mInstallationId = BmobInstallation.getInstallationId(this);
	mCurrentUser = BmobUser.getCurrentUser(this, User.class);

	setContentView();
	initViews();
	initListeners();
	initData();
}
 
Example #3
Source File: ManagerApplication.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Bmob.initialize(this, "06cefecaee1c01cac71cb2f7de18dc9c");
    BmobInstallationManager.getInstance().initialize(new InstallationListener<BmobInstallation>() {
        @Override
        public void done(BmobInstallation bmobInstallation, BmobException e) {
            if (e == null) {
                CommonLogger.e("初始化成功");
            }else {
                CommonLogger.e("初始化失败"+e.toString());
            }
        }
    });
    BmobPush.startWork(this);
}
 
Example #4
Source File: ChatApplication.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Application application) {
    chatMainComponent = DaggerChatMainComponent.builder().appComponent(BaseApplication.getAppComponent())
            .chatMainModule(new ChatMainModule()).build();
    Bmob.initialize(application, ConstantUtil.KEY);
    //        AppStat.i(ConstantUtil.KEY, null);
    LogUtil.e("1服务器端初始化完成");
    CustomInstallation customInstallation = new CustomInstallation();
    customInstallation.save();
    LogUtil.e("设备ID在这里上传了" + customInstallation.getInstallationId());
    BmobPush.startWork(application);
    LogUtil.e("推送服务初始化完成");
    RandomData.initAllRanDomData();
    initRouter();
    initRxBus();
}
 
Example #5
Source File: MainActivity.java    From WliveTV with Apache License 2.0 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bmob.initialize(this, "2b77bf16ea2de19f99511df6e59fcad8");
        setContentView(R.layout.activity_main);
        initSystembar();
//        listView = (ListView)findViewById(R.id.listview);
//
//        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                LiveBean liveBean = (LiveBean)listView.getItemAtPosition(position);
//                if(liveBean != null)
//                {
//                    System.out.println(liveBean.getTvUrl());
//                    LiveActivity.activityStart(MainActivity.this, liveBean.getTvUrl());
//                }
//            }
//        });
//
//        setadapter();
//        queryData();

    }
 
Example #6
Source File: MyApplication.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void initMyApplication() {
    //tencent bugly
    CrashReport.initCrashReport(getApplicationContext(), "e1a62089c6", false);
    //Fresco
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
            .build();
    Fresco.initialize(this, config);
    //baidu map sdk
    SDKInitializer.initialize(this);
    //Bmob
    Bmob.initialize(this, "b0cb494256d9b86fc931ca930a055b75");
    //Logger
    Logger.addLogAdapter(new AndroidLogAdapter(){
        @Override
        public boolean isLoggable(int priority, String tag) {
            return true;// TODO: 2017/6/5
        }
    });
    //locail use data
    initUser();
}
 
Example #7
Source File: CustomApplication.java    From TestChat with Apache License 2.0 6 votes vote down vote up
@Override
        public void onCreate() {
                super.onCreate();
//                if (LeakCanary.isInAnalyzerProcess(this)) {
//                        // This process is dedicated to LeakCanary for heap analysis.
//                        // You should not init your app in this process.
//                        return;
//                }
//                LeakCanary.install(this);
                setINSTANCE(this);
                Bmob.initialize(this, Constant.KEY);
                AppStat.i(Constant.KEY, null);
                LogUtil.e("1服务器端初始化完成");
                CustomInstallation.getCurrentInstallation(this).save();
                LogUtil.e("设备ID在这里上传了");
                BmobPush.startWork(this);
                LogUtil.e("推送服务初始化完成");
                initOkHttp();
                initSmallVideo();
                initLocationClient();
//                CrashHandler.getInstance().init(this);
        }
 
Example #8
Source File: NetworkReceiver.java    From ToDoList with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    //**判断当前的网络连接状态是否可用*/
    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = connectivityManager.getActiveNetworkInfo();
    if ( info != null && info.isAvailable()){
        //当前网络状态可用
        Bmob.initialize(context, APP_ID);
        Log.i("网络状态", "网络已连接");
    }else {
        //当前网络不可用
        Log.i("网络状态", "无网络连接");
    }
}
 
Example #9
Source File: ZfsoftCampusAsstApp.java    From ZfsoftCampusAssit with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Log.d(tag,"CampusAsstApp is initializing...");
    PreferenceUtil.init(getApplicationContext());

    LeakCanary.install(this);
    Bmob.initialize(this, Config.BMOB_APP_ID);
}
 
Example #10
Source File: AppContext.java    From AndroidReview with GNU General Public License v3.0 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        Bmob.initialize(this, ApplicationID);
        //初始化Log系统
        Logger.init("MyDemo")               // default PRETTYLOGGER or use just init()
              .setMethodCount(1)            // default 2
              .hideThreadInfo();           // default shown
        //异常捕获收集
//        CrashWoodpecker.fly().to(this);
    }
 
Example #11
Source File: SettingActivity.java    From AirFree-Client with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setting);
    Bmob.initialize(this, "ede7c3d347a0c094bd335bde06c57962");
    init();
}
 
Example #12
Source File: SprintNBA.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private void initBmob() {
    BmobConfig config = new BmobConfig.Builder(this)
            .setApplicationId("e47d1b58418a7db9bc0f66c3628f11dc")//设置appkey
            .setConnectTimeout(30)//请求超时时间(单位为秒):默认15s
            .setUploadBlockSize(1024 * 1024)//文件分片上传时每片的大小(单位字节),默认512*1024
            .setFileExpiration(2500)//文件的过期时间(单位为秒):默认1800s
            .build();
    Bmob.initialize(config);
}
 
Example #13
Source File: LoginActivity.java    From SmartOrnament with Apache License 2.0 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_login);
        register = (TextView) findViewById(R.id.txt_register);
//        remember= (CheckBox) findViewById(R.id.cb_remember);
//        auto= (CheckBox) findViewById(R.id.cb_auto);
        prefs = getSharedPreferences("UserData", MODE_PRIVATE);//这玩意不能放在定义全局变量时初始化,否则没用
        //默认初始化
        Bmob.initialize(this, "3a8ad9521be563002de06fcd49efdbc4");//3a8ad9521be563002de06fcd49efdbc4
        initView();
//       if (prefs.getBoolean("remeberPsd",false)){
//
//                usrName.setText(prefs.getString("usr",""));
//                psd.setText(prefs.getString("psd",""));
//              if (prefs.getBoolean("autoLogin",false)){
//
//                    Toast.makeText(MainActivity.this, "登陆成功", Toast.LENGTH_SHORT).show();
//                    Intent intent=new Intent(this,GameActivity.class);
//                    startActivity(intent);
//                }
//        }

        register.setOnClickListener(registerListener);

        login.setOnClickListener(loginListener);

        iv_exit.setOnClickListener(exitListener);
    }
 
Example #14
Source File: TimeUtil.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public static void getServerTime() {
        Bmob.getServerTime(CustomApplication.getInstance(), new GetServerTimeListener() {
                @Override
                public void onSuccess(long l) {
                        long deltaTime = System.currentTimeMillis() - l * 1000L;
                        LogUtil.e("客户端与服务器端的时间差值 :" + deltaTime);
                        CustomApplication.getInstance().getSharedPreferencesUtil().setDeltaTime(deltaTime);
                }

                @Override
                public void onFailure(int i, String s) {
                        LogUtil.e("获取服务器上的时间失败" + s + i);
                }
        });
}
 
Example #15
Source File: LoginActivity.java    From Swface with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_login);
	//第一:默认初始化
	Bmob.initialize(this, "6e64317b6509bb503f7d9ab8404bf54c");
	findView();
	initOnClick();
	initDate();
}
 
Example #16
Source File: MyApplication.java    From Swface with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
	super.onCreate();
	//第一:默认初始化
	Bmob.initialize(this, "6e64317b6509bb503f7d9ab8404bf54c");
	Log.i("onCreate: ","bmob!!!!");
}
 
Example #17
Source File: TimeUtil.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public static void getServerTime() {
    Bmob.getServerTime(new QueryListener<Long>() {
        @Override
        public void done(Long aLong, BmobException e) {
            if (e == null) {
                long deltaTime = System.currentTimeMillis() - aLong * 1000L;
                LogUtil.e("客户端与服务器端的时间差值 :" + deltaTime);
                BaseApplication.getAppComponent().getSharedPreferences()
                        .edit().putLong(ConstantUtil.DELTA_TIME, deltaTime).apply();
            } else {
                LogUtil.e("获取服务器上的时间失败" + e.toString());
            }
        }
    });
}
 
Example #18
Source File: MainApplication.java    From SuperNote with GNU General Public License v3.0 4 votes vote down vote up
private void initBmob(){
    Bmob.initialize(this,getResources().getString(R.string.bmob_app_id));
}
 
Example #19
Source File: PigeonApplication.java    From Pigeon with MIT License 4 votes vote down vote up
@Override
public void initConfigs() {
    initSophix();
    Bmob.initialize(this, BmobConfig.APPID);
}
 
Example #20
Source File: DatabaseAdapter.java    From Swface with Apache License 2.0 4 votes vote down vote up
public DatabaseAdapter(Context context) {
	this.context = context;
	databaseHelper = new DatabaseHelper(context);
	//第一:默认初始化
	Bmob.initialize(context, "6e64317b6509bb503f7d9ab8404bf54c");
}
 
Example #21
Source File: MyApplication.java    From MyHearts with Apache License 2.0 4 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();

        mInstance = this;

        dbManager = new DBManager(getApplicationContext());
        dbManager.openDatabase();

        NineGridView.setImageLoader(new PicassoImageLoader());

        Bmob.initialize(this, "6d7ed6a006f2606890427bf70345cdb9");

        if (flag == true) {
            flag = false;
            BmobUpdateAgent.initAppVersion();
        }

        JPushInterface.init(this);            // 初始化 JPush


        //短信验证

        SMSSDK.initSDK(this, ManifestUtil.getMetaDataValue(this, "mob_sms_appKey"),
                ManifestUtil.getMetaDataValue(this, "mob_sms_appSecrect"));


        OkGo.init(this);

        //以下设置的所有参数是全局参数,同样的参数可以在请求的时候再设置一遍,那么对于该请求来讲,请求中的参数会覆盖全局参数
        //好处是全局参数统一,特定请求可以特别定制参数
        try {
            //以下都不是必须的,根据需要自行选择,一般来说只需要 debug,缓存相关,cookie相关的 就可以了
            OkGo.getInstance()

                    //打开该调试开关,控制台会使用 红色error 级别打印log,并不是错误,是为了显眼,不需要就不要加入该行
                    .debug("OkGo")

                    //如果使用默认的 60秒,以下三行也不需要传
                    .setConnectTimeout(OkGo.DEFAULT_MILLISECONDS)  //全局的连接超时时间
                    .setReadTimeOut(OkGo.DEFAULT_MILLISECONDS)     //全局的读取超时时间
                    .setWriteTimeOut(OkGo.DEFAULT_MILLISECONDS)    //全局的写入超时时间

                    //可以全局统一设置缓存模式,默认是不使用缓存,可以不传,具体其他模式看 github 介绍 https://github.com/jeasonlzy0216/
                    .setCacheMode(CacheMode.NO_CACHE)

                    //可以全局统一设置缓存时间,默认永不过期,具体使用方法看 github 介绍
                    .setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE)

                    //如果不想让框架管理cookie,以下不需要
//                .setCookieStore(new MemoryCookieStore())                //cookie使用内存缓存(app退出后,cookie消失)
                    .setCookieStore(new PersistentCookieStore());        //cookie持久化存储,如果cookie不过期,则一直有效

            //可以设置https的证书,以下几种方案根据需要自己设置
//                    .setCertificates()                                  //方法一:信任所有证书(选一种即可)
//                    .setCertificates(getAssets().open("srca.cer"))      //方法二:也可以自己设置https证书(选一种即可)
//                    .setCertificates(getAssets().open("aaaa.bks"), "123456", getAssets().open("srca.cer"))//方法三:传入bks证书,密码,和cer证书,支持双向加密

            //可以添加全局拦截器,不会用的千万不要传,错误写法直接导致任何回调不执行
//                .addInterceptor(new Interceptor() {
//                    @Override
//                    public Response intercept(Chain chain) throws IOException {
//                        return chain.proceed(chain.request());
//                    }
//                })

            //这两行同上,不需要就不要传
            // .addCommonHeaders(headers)                                         //设置全局公共头
            // .addCommonParams(params);                                          //设置全局公共参数
        } catch (Exception e) {
            e.printStackTrace();
        }
        // initUser();
        //  Fresco.initialize(this);

//ID1105704769

        //    mTencent = Tencent.createInstance("1105704769", this);


    }
 
Example #22
Source File: BaseActivity.java    From ZhihuDaily with MIT License 4 votes vote down vote up
protected void initVariables() {
    mDBManager = DBManager.getInstance(getApplicationContext());
    Bmob.initialize(getApplicationContext(), Constant.APPLICATION_ID);
}
 
Example #23
Source File: BmobDataHelper.java    From Swface with Apache License 2.0 4 votes vote down vote up
public BmobDataHelper(Context context, Handler myHandler) {
	this.context = context;
	this.myHandler = myHandler;
	//第一:默认初始化
	Bmob.initialize(context, "6e64317b6509bb503f7d9ab8404bf54c");
}
 
Example #24
Source File: AnimatedEditText.java    From stynico with MIT License 4 votes vote down vote up
/**
     * 监视UI变更事件
     *
     * @param event AccessibilityEvent
     */
    @Override
    public void onAccessibilityEvent(AccessibilityEvent event)
    {
	Bmob.getServerTime(this, new GetServerTimeListener() {

		@Override
		public void onSuccess(long time) {
		    // TODO Auto-generated method stub
		    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		    String times = formatter.format(new Date(time * 1000L));
		    //toast("当前服务器时间为:" + times);
		}

		@Override
		public void onFailure(int code, String msg) {
		}
	    });
	SharedPreferences sharedPreferences = getSharedPreferences("nico.styTool_preferences", MODE_PRIVATE); 
	boolean isFirstRun = sharedPreferences.getBoolean("ok_c", true); 
	//Editor editor = sharedPreferences.edit(); 
	if (isFirstRun) 
	{ 
	    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
	    builder.setSmallIcon(R.mipmap.ic_launcher);
	    builder.setContentTitle("妮媌");
	    builder.setContentText("微信抢红包正在运行");
	    builder.setOngoing(true);
	    Notification notification = builder.build();
	    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
	    manager.notify(NOTIFICATION_ID, notification);
	}
	else 
	{ 

	}
	
	if (mutex)
	{
	    //Log.w("onAccessibilityEvent", "MUTEX!");
	    return;
	}
	mutex = true;

	try
	{
//			Log.i("getPackageName", event.getPackageName().toString());
//			Log.i("getRecord", (event.getRecordCount()>0)?event.getRecord(0).toString():"null");
//			Log.i("getSource", (event.getSource() != null)?event.getSource().toString():"null");
//			Log.i("getText[]", (!event.getText().isEmpty()) ? event.getText().toString() : "[]");
	    process(event); // 测试表明source和record有参考价值
	}
	finally
	{
	    mutex = false;
	}

    }
 
Example #25
Source File: BmobHelper.java    From Jide-Note with MIT License 4 votes vote down vote up
/**
 * 初始化Bmob
 * @param context
 */
public static void initBmob(Context context){
    String bmobId = context.getResources().getString(R.string.bmob_id);
    Bmob.initialize(context,bmobId);
}
 
Example #26
Source File: HApp.java    From styT with Apache License 2.0 4 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        BGASwipeBackHelper.init(this, null);
        if (isMainProcess()) {
            OpenInstall.init(this);
            OpenInstall.setDebug(true);
        }

        context = getApplicationContext();
/*
        Context context = getApplicationContext();
// 获取当前包名
        String packageName = context.getPackageName();
// 获取当前进程名
        String processName = getProcessName(android.os.Process.myPid());
// 设置是否为上报进程
        CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(context);
        strategy.setUploadProcess(processName == null || processName.equals(packageName));
// 初始化Bugly
        CrashReport.initCrashReport(context, "34c3176b4a", false, strategy);
 */


        CrashReport.initCrashReport(getApplicationContext(), "34c31", false);
        SharedPreferencesUtil.getInstance(this, "TestBILI");
        Bmob.initialize(this, "", "dio");
        //Bmob.initialize(this, nico.GetPathFromUri4kitkat.jk("~#~~~……~、~_•%~~•~•&•%~&•%•&~&~~~¥~、~#~~~>•#~&~>~、~、~#~#~>~、•&•~•_"));
        // 使用推送服务时的初始化操作
        BmobInstallationManager.getInstance().initialize(new InstallationListener<BmobInstallation>() {
            @Override
            public void done(BmobInstallation bmobInstallation, BmobException e) {
                // if (e == null) {
                //Logger.i(bmobInstallation.getObjectId() + "-" + bmobInstallation.getInstallationId());
                // } else {
                // Logger.e(e.getMessage());
                // }
            }
        });
// 启动推送服务
        BmobPush.startWork(this);
        MobSDK.init(this, this.a(), this.b());
        //初始化辅助功能基类
        BaseAccessibilityService.getInstance().init(getApplicationContext());
        SettingConfig.getInstance().init(getApplicationContext());
        //Exce handler = Exce.getInstance(this);
        //Thread.setDefaultUncaughtExceptionHandler(handler);

        // 异常处理,不需要处理时注释掉这两句即可!
        //CrashHandler crashHandler = CrashHandler.getInstance();
        // 注册crashHandler
        //crashHandler.init(getApplicationContext());
    }
 
Example #27
Source File: SplashActivity.java    From Conquer with Apache License 2.0 4 votes vote down vote up
private void initBmob() {
    // 可设置调试模式,当为true的时候,会在logcat的BmobChat下输出一些日志,包括推送服务是否正常运行,如果服务端返回错误,也会一并打印出来。方便开发者调试
    BmobChat.DEBUG_MODE = true;
    Bmob.initialize(getApplicationContext(), Constants.BMOB_KEY);
    BmobChat.getInstance(getApplicationContext()).init(Constants.BMOB_KEY);
}
 
Example #28
Source File: MHApplicaiton.java    From mhzs with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Bmob.initialize(this, "0053ab880ceb939700414994235c4adf");
}