Java Code Examples for cn.jpush.android.api.JPushInterface#getRegistrationID()

The following examples show how to use cn.jpush.android.api.JPushInterface#getRegistrationID() . 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 QuickNews with MIT License 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fresco.initialize(this);
        JPushInterface.init(this);
        System.out.println("JPushInterface.getRegistrationID");
        JPushInterface.init(getApplicationContext());
        String rid = JPushInterface.getRegistrationID(getApplicationContext());
        System.out.println("JPushInterface.getRegistrationID" + rid);
        setContentView(R.layout.activity_main);
        ActionBar actionBar = getSupportActionBar();
        actionBar.hide();


        initView();


        mNetReceiver = new NetWorkChangeReceiver();
        IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
        registerReceiver(mNetReceiver, filter);
        NetWorkState.mNetState = NetWorkState.isConn(MainActivity.this);


//        registerMessageReceiver();  // used for receive msg

    }
 
Example 2
Source File: MainActivity.java    From HaiNaBaiChuan with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
	int i = v.getId();
	if (i == R.id.init) {
		init();

	} else if (i == R.id.setting) {
		Intent intent = new Intent(MainActivity.this, PushSetActivity.class);
		startActivity(intent);

	} else if (i == R.id.stopPush) {
		JPushInterface.stopPush(getApplicationContext());

	} else if (i == R.id.resumePush) {
		JPushInterface.resumePush(getApplicationContext());

	} else if (i == R.id.getRegistrationId) {
		String rid = JPushInterface.getRegistrationID(getApplicationContext());
		if (!TextUtils.isEmpty(rid)) {
			mRegId.setText("RegId:" + rid);
		} else {
			Toast.makeText(this, "Get registration fail, JPush init failed!", Toast.LENGTH_SHORT).show();
		}

	}
}
 
Example 3
Source File: GosPushManager.java    From GOpenSource_AppKit_Android_AS with MIT License 6 votes vote down vote up
public static void pushUnBindService(String token) {

		if (token.isEmpty()) {
			return;
		}

		if (GizPushType.GizPushJiGuang == gizPushType) {
			// 获取JPush的RegistrationID,即Channel_ID
			Channel_ID = JPushInterface.getRegistrationID(context);
		} else if (GizPushType.GizPushBaiDu == gizPushType) {
			// 获取BDPush的Channel_ID
			Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
		} else {
			return;
		}
		// TODO 绑定推送
		Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
		GizWifiSDK.sharedInstance().channelIDUnBind(token, Channel_ID);
	}
 
Example 4
Source File: GosPushManager.java    From Gizwits-SmartBuld_Android with MIT License 6 votes vote down vote up
public static void pushUnBindService(String token) {

		if (token.isEmpty()) {
			return;
		}

		if (GizPushType.GizPushJiGuang == gizPushType) {
			// 获取JPush的RegistrationID,即Channel_ID
			Channel_ID = JPushInterface.getRegistrationID(context);
		} else if (GizPushType.GizPushBaiDu == gizPushType) {
			// 获取BDPush的Channel_ID
			Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
		} else {
			return;
		}
		// TODO 绑定推送
		Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
		GizWifiSDK.sharedInstance().channelIDUnBind(token, Channel_ID);
	}
 
Example 5
Source File: GosPushManager.java    From gokit-android with MIT License 6 votes vote down vote up
public static void pushUnBindService(String token) {

		if (token.isEmpty()) {
			return;
		}

		if (GizPushType.GizPushJiGuang == gizPushType) {
			// 获取JPush的RegistrationID,即Channel_ID
			Channel_ID = JPushInterface.getRegistrationID(context);
		} else if (GizPushType.GizPushBaiDu == gizPushType) {
			// 获取BDPush的Channel_ID
			Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
		} else {
			return;
		}
		// TODO 绑定推送
		Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
		GizWifiSDK.sharedInstance().channelIDUnBind(token, Channel_ID);
	}
 
Example 6
Source File: GosPushManager.java    From GOpenSource_AppKit_Android_AS with MIT License 5 votes vote down vote up
/**
 * 向云端绑定推送
 * 
 * @param Token
 * @param Channel_ID
 * @param gizPushType
 */
public static void pushBindService(String token) {

	if (GizPushType.GizPushJiGuang == gizPushType) {
		// 获取JPush的RegistrationID,即Channel_ID
		Channel_ID = JPushInterface.getRegistrationID(context);

		// 设定JPush类型
		JPushInterface.setAlias(context, Channel_ID, new TagAliasCallback() {
			@Override
			public void gotResult(int arg0, String arg1, Set<String> arg2) {
				if (arg0 == 0) {
					Log.i("Apptest", "Alias: " + arg1);
				} else {
					Log.e("Apptest", "Result: " + arg0);
				}
			}
		});

	} else if (GizPushType.GizPushBaiDu == gizPushType) {
		// 获取BDPush的Channel_ID
		Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
	} else {
		return;
	}

	// TODO 绑定推送
	Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
	GizWifiSDK.sharedInstance().channelIDBind(token, Channel_ID, gizPushType);
}
 
Example 7
Source File: GosPushManager.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
/**
 * 向云端绑定推送
 * 
 * @param Token
 * @param Channel_ID
 * @param gizPushType
 */
public static void pushBindService(String token) {

	if (GizPushType.GizPushJiGuang == gizPushType) {
		// 获取JPush的RegistrationID,即Channel_ID
		Channel_ID = JPushInterface.getRegistrationID(context);

		// 设定JPush类型
		JPushInterface.setAlias(context, Channel_ID, new TagAliasCallback() {
			@Override
			public void gotResult(int arg0, String arg1, Set<String> arg2) {
				if (arg0 == 0) {
					Log.i("Apptest", "Alias: " + arg1);
				} else {
					Log.e("Apptest", "Result: " + arg0);
				}
			}
		});

	} else if (GizPushType.GizPushBaiDu == gizPushType) {
		// 获取BDPush的Channel_ID
		Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
	} else {
		return;
	}

	// TODO 绑定推送
	Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
	GizWifiSDK.sharedInstance().channelIDBind(token, Channel_ID, gizPushType);
}
 
Example 8
Source File: GosPushManager.java    From gokit-android with MIT License 5 votes vote down vote up
/**
 * 向云端绑定推送
 * 
 * @param Token
 * @param Channel_ID
 * @param gizPushType
 */
public static void pushBindService(String token) {

	if (GizPushType.GizPushJiGuang == gizPushType) {
		// 获取JPush的RegistrationID,即Channel_ID
		Channel_ID = JPushInterface.getRegistrationID(context);

		// 设定JPush类型
		JPushInterface.setAlias(context, Channel_ID, new TagAliasCallback() {
			@Override
			public void gotResult(int arg0, String arg1, Set<String> arg2) {
				if (arg0 == 0) {
					Log.i("Apptest", "Alias: " + arg1);
				} else {
					Log.e("Apptest", "Result: " + arg0);
				}
			}
		});

	} else if (GizPushType.GizPushBaiDu == gizPushType) {
		// 获取BDPush的Channel_ID
		Channel_ID = BaiDuPushReceiver.BaiDuPush_Channel_ID;
	} else {
		return;
	}

	// TODO 绑定推送
	Log.i("Apptest", Channel_ID + "\n" + gizPushType.toString() + "\n" + token);
	GizWifiSDK.sharedInstance().channelIDBind(token, Channel_ID, gizPushType);
}