com.tencent.android.tpush.XGPushManager Java Examples

The following examples show how to use com.tencent.android.tpush.XGPushManager. 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: MainActivity.java    From STUer-client with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.inject(this);

    // 注册网络变化广播,必须放在夜间模式前,否则recreate时回调onDestroy时unregister出错
    IntentFilter intentFilter = new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE");
    registerReceiver(mNetChangedReceiver, intentFilter);

    // 首次进入跳转到LoginActivity
    if (!SPUtils.getBoolean(LoginActivity.IS_REGISTER)) {
        startActivity(new Intent(this, LoginActivity.class));
        finish();
        return;  // must return here
    }

    // XingePush
    Context context = getApplicationContext();
    XGPushManager.registerPush(context, AppInfoUtils.getImei());

    // 事件总线
    EventBus.getDefault().register(this);

    // 状态栏
    UiUtils.setTranslucentStatusBar(this, mNavigationView);

    // 夜间模式
    if (UiUtils.isNightMode(this)) {
        return;
    }

    // 检查更新
    if (SettingUtils.autoCheckUpdate()) {
        mUpdatePresenter = new UpdatePresenter(this);
        mUpdatePresenter.checkNewVersion();
    }

    initToolbar();
    initNavigationView();
    initFab();
    initFragment();
}
 
Example #2
Source File: ShowLuntanActivity.java    From xmpp with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_luntan);
    instance=this;
    users = SaveUserUtil.loadAccount(this);
    result = XGPushManager.onActivityStarted(ShowLuntanActivity.this);
    if (result != null) {
        xg_bool = true;
        // 获取自定义key-value
        String customContent = result.getCustomContent();
        if (customContent != null && customContent.length() != 0) {
            try {
                JSONObject obj = new JSONObject(customContent);
                // key1为前台配置的key
                if (!obj.isNull("data")) {
                    news_luntan = new News_luntan();
                    String data = obj.getString("data");
                    JSONObject object = new JSONObject(data);
                    User userr = new User();
                    userr.setUser(object.getString("user"));
                    userr.setNickname(object.getString("nickname"));
                    userr.setIcon(object.getString("icon"));
                    userr.setSex(object.getString("sex"));
                    news_luntan.setUser(userr);
                    news_luntan.setLid(object.getInt("lid"));
                    news_luntan.setContent(object.getString("content"));
                    news_luntan.setImage(object.getString("image"));
                    news_luntan.setTime(object.getString("time"));
                    news_luntan.setLocation(object.getString("location"));


                }
                // ...
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    } else {
        intent = getIntent();
        news_luntan = (News_luntan) intent.getSerializableExtra("news_luntan");

    }


    initialView();

}