当前位置: 首页>>代码示例>>Java>>正文


Java PushConstants类代码示例

本文整理汇总了Java中com.baidu.android.pushservice.PushConstants的典型用法代码示例。如果您正苦于以下问题:Java PushConstants类的具体用法?Java PushConstants怎么用?Java PushConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PushConstants类属于com.baidu.android.pushservice包,在下文中一共展示了PushConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onReceive

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
	if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
		//开机启动激活服务
		openAlarm(context);
		delayRequestCheckBgdServiceStatus(context);
	}else if (intent.getAction().equals(ACTION_BGD_SERVICE)){
           Intent myIntent = new Intent(context, BgdService.class);
           context.startService(myIntent);
	}else if (intent.getAction().equals(CONNECTIVITY_ACTION)){
		if (HttpUtil.isNetworkConnected(context)){
			//绑定百度云推送
			if(!PushManager.isPushEnabled(context)){
				PushManager.startWork(context,
						PushConstants.LOGIN_TYPE_API_KEY,
						MyApp.API_KEY);
			}
		}
	}
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:21,代码来源:MyBroadcastReceiver.java

示例2: initData

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
/**
    * 初始化数据
    */
   private void initData() {
   	trainId = cContent.getTrainNum();
   	chatRoomTag = cContent.getPushTag();
	messageDB = MyApp.getInstance().getMessageDB();
	userInfoSPUtil = MyApp.getInstance().getUserInfoSPUtil();
	//初始化表情文字
	mFacemap = TT.getFaceMap();
	faceKeysList.addAll(mFacemap.keySet());
	messageAdapter = new MessageAdapter(getActivity(), messageDB.getMessage(trainId,MsgPagerNum), mFacemap);
	//检查push服务是否开启
	if(!PushManager.isPushEnabled(getActivity())){
		PushManager.startWork(getActivity(),
				PushConstants.LOGIN_TYPE_API_KEY,
				MyApp.API_KEY);
	}
	
	
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:22,代码来源:ChatRoomFragment.java

示例3: onCreate

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_splash);

    boolean startFromNotification = getIntent().getBooleanExtra(MainActivity.ARG_FROM_TIMER_NOTIFICATION, false);
    if(startFromNotification){
        StatUtils.onEvent(StatUtils.EVENT_NOTIFICATION_LAUNCH);
    }

    LocalHandler handler = new LocalHandler(this);
    handler.setStartTime(System.currentTimeMillis());
    handler.setStartFromNotification(startFromNotification);

    new Thread(new InitRunnable(this, handler)).start();

    // 启动百度push
    PushManager.startWork(this, PushConstants.LOGIN_TYPE_API_KEY, BaiduPushReceiver.API_KEY);

    // 注册微信分享sdk
    ShareUtil.register();

    DataSharedPreferences.setStartTime();
}
 
开发者ID:CyanFlxy,项目名称:KnockKnock,代码行数:27,代码来源:SplashActivity.java

示例4: onNewIntent

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
    String action = intent.getAction();

    if (Utils.ACTION_LOGIN.equals(action)) {
        // Push: 百度账号初始化,用access token绑定
        String accessToken = intent
                .getStringExtra(Utils.EXTRA_ACCESS_TOKEN);
        PushManager.startWork(getApplicationContext(),
                PushConstants.LOGIN_TYPE_ACCESS_TOKEN, accessToken);

        isLogin = true;
        initButton.setText("更换百度账号");
    }

    updateDisplay();
}
 
开发者ID:leonardo-hammer,项目名称:H5P.Plugins.push.baidu,代码行数:18,代码来源:PushDemoActivity.java

示例5: onCreate

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	Resources resource = this.getResources();
	String pkgName = this.getPackageName();
	
	setContentView(resource.getIdentifier("custom_activity", "layout", pkgName));

	TextView titleView = (TextView) this.findViewById(resource.getIdentifier("title", "id", pkgName));
	TextView contentView = (TextView) this.findViewById(resource.getIdentifier("content", "id", pkgName));
	
	Intent intent = getIntent();
       String title = intent.getStringExtra(PushConstants.EXTRA_NOTIFICATION_TITLE);
       String content = intent.getStringExtra(PushConstants.EXTRA_NOTIFICATION_CONTENT);
       
       titleView.setText(title);
       contentView.setText(content);
}
 
开发者ID:yulingtianxia,项目名称:ChangYou,代码行数:20,代码来源:CustomActivity.java

示例6: bDPush

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
public void bDPush() {
	final String BDPushAppKey = GosDeploy.setBaiDuPushAppKey();
	if (TextUtils.isEmpty(BDPushAppKey) || BDPushAppKey.contains("your_bpush_api_key")) {
		GosBaseActivity.noIDAlert(context, R.string.BDPushAppID_Toast);
	} else {

		PushManager.startWork(context, PushConstants.LOGIN_TYPE_API_KEY, BDPushAppKey);
		PushSettings.enableDebugMode(context, true);

	}

}
 
开发者ID:gizwits,项目名称:GOpenSource_AppKit_Android_AS,代码行数:13,代码来源:GosPushManager.java

示例7: bDPush

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
public void bDPush() {
	String BDPushAppKey = GosDeploy.setBaiDuPushAppKey();
	if (TextUtils.isEmpty(BDPushAppKey) || BDPushAppKey.contains("your_bpush_api_key")) {
		Toast.makeText(context, R.string.BDPushAppID_Toast, 2000).show();
	} else {
		PushManager.startWork(context, PushConstants.LOGIN_TYPE_API_KEY, BDPushAppKey);
	}

}
 
开发者ID:gizwits,项目名称:Gizwits-SmartBuld_Android,代码行数:10,代码来源:GosPushManager.java

示例8: startWork

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
/**
 * 给javascript通过PluginBridge调用的原生方法
 * 用来注册百度云推送的服务
 * 
 * @param pWebview 当前的Webview对象
 * @param array 参数数组
 */
public void startWork(IWebview pWebview, JSONArray array) {
	String callbackId = array.optString(0);
	
	// 记录下当前注册百度云推送的回调id和Webview对象,之后方便回调
	BaiduPushContext pushContext = BaiduPushContext.getInstance();
	
	pushContext.pushOnBindCallBackId = callbackId;
	pushContext.pushOnBindWebview = pWebview;
	
	String apiKey = array.optString(1);
	
	// 注册百度云PUSH
	PushManager.startWork(this.mApplicationContext, PushConstants.LOGIN_TYPE_API_KEY, apiKey);
}
 
开发者ID:leonardo-hammer,项目名称:H5P.Plugins.push.baidu,代码行数:22,代码来源:BaiduPushManager.java

示例9: initWithApiKey

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
private void initWithApiKey() {
    // Push: 无账号初始化,用api key绑定
    // checkApikey();
    PushManager.startWork(getApplicationContext(),
            PushConstants.LOGIN_TYPE_API_KEY,
            Utils.getMetaValue(PushDemoActivity.this, "api_key"));
}
 
开发者ID:leonardo-hammer,项目名称:H5P.Plugins.push.baidu,代码行数:8,代码来源:PushDemoActivity.java

示例10: onReceive

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(PushConstants.ACTION_MESSAGE)) {
        String message = intent.getExtras().getString(
                PushConstants.EXTRA_PUSH_MESSAGE_STRING);
        Log.e("message","message : "+message);
    } else if (intent.getAction().equals(PushConstants.ACTION_RECEIVE)) {
        // 处理绑定等方法的返回数据
        // PushManager.startWork()的返回值通过PushConstants.METHOD_BIND得到

        // 获取方法
        final String method = intent
                .getStringExtra(PushConstants.EXTRA_METHOD);
        // 方法返回错误码。若绑定返回错误(非0),则应用将不能正常接收消息。
        // 绑定失败的原因有多种,如网络原因,或access token过期。
        // 请不要在出错时进行简单的startWork调用,这有可能导致死循环。
        // 可以通过限制重试次数,或者在其他时机重新调用来解决。
        int errorCode = intent.getIntExtra(PushConstants.EXTRA_ERROR_CODE,
                PushConstants.ERROR_SUCCESS);
        String content = "";
        if (intent.getByteArrayExtra(PushConstants.EXTRA_CONTENT) != null) {
            // 返回内容
            content = new String(
                    intent.getByteArrayExtra(PushConstants.EXTRA_CONTENT));
            Log.e("Test","content : "+content);
        }
    }else if (intent.getAction().equals(
            PushConstants.ACTION_RECEIVER_NOTIFICATION_CLICK)){
        String customContent = intent.getExtras().getString(
                PushConstants.EXTRA_EXTRA, "");
        Log.e("cus","cue : "+customContent);
    }
}
 
开发者ID:offerHere,项目名称:offer,代码行数:34,代码来源:PushMessageReceiver.java

示例11: init

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
void init(CordovaInterface cordova) {
    Resources resource = cordova.getActivity().getResources();
    String pkgName = cordova.getActivity().getPackageName();
    // Push: 以apikey的方式登录,一般放在主Activity的onCreate中。
    // 这里把apikey存放于manifest文件中,只是一种存放方式,
    // 您可以用自定义常量等其它方式实现,来替换参数中的Utils.getMetaValue(PushDemoActivity.this,
    // "api_key")
    // 通过share preference实现的绑定标志开关,如果已经成功绑定,就取消这次绑定
    if (!Utils.hasBind(cordova.getActivity().getApplicationContext())) {
        //!! 请将AndroidManifest.xml 104行处 api_key 字段值修改为自己的 api_key 方可使用 !!
        //!! ATTENTION:You need to modify the value of api_key to your own at row 104 in AndroidManifest.xml to use this Demo !!
        PushManager.startWork(cordova.getActivity().getApplicationContext(),
                PushConstants.LOGIN_TYPE_API_KEY,
                Utils.getMetaValue(cordova.getActivity(), "api_key"));
        // Push: 如果想基于地理位置推送,可以打开支持地理位置的推送的开关
        // PushManager.enableLbs(getApplicationContext());
    }

    // Push: 设置自定义的通知样式,具体API介绍见用户手册,如果想使用系统默认的可以不加这段代码
    // 请在通知推送界面中,高级设置->通知栏样式->自定义样式,选中并且填写值:1,
    // 与下方代码中 PushManager.setNotificationBuilder(this, 1, cBuilder)中的第二个参数对应
    CustomPushNotificationBuilder cBuilder = new CustomPushNotificationBuilder(
            cordova.getActivity().getApplicationContext(), resource.getIdentifier(
            "notification_custom_builder", "layout", pkgName),
            resource.getIdentifier("notification_icon", "id", pkgName),
            resource.getIdentifier("notification_title", "id", pkgName),
            resource.getIdentifier("notification_text", "id", pkgName)
    );
    cBuilder.setNotificationFlags(Notification.FLAG_AUTO_CANCEL);
    cBuilder.setNotificationDefaults(Notification.DEFAULT_SOUND
            | Notification.DEFAULT_VIBRATE);
    cBuilder.setStatusbarIcon(cordova.getActivity().getApplicationInfo().icon);
    cBuilder.setLayoutDrawable(resource.getIdentifier(
            "simple_notification_icon", "drawable", pkgName));
    PushManager.setNotificationBuilder(cordova.getActivity(), notificationBuilderId, cBuilder);

    //callbackContext.success();

}
 
开发者ID:rocleegithub,项目名称:baidupush-phonegap-plugin,代码行数:40,代码来源:PushService.java

示例12: onCreate

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	
			
	userInfo = this.getSharedPreferences("setting", Context.MODE_PRIVATE);
	global = Global.getInstance(userInfo.getString("dm_user", ""));

	Boolean login = userInfo.getBoolean("login", true);
	if (login) {
		startActivity(new Intent(IndexActivity.this, MainActivity.class));
		finish();
	}
	// ������
	if (Global.CheckNetwork(IndexActivity.this)) {
		this.updateMan = new UpdateManager(IndexActivity.this, appUpdateCb);
		this.updateMan.checkUpdate();
		if (!Utils.hasBind(getApplicationContext())) {
			PushManager.startWork(getApplicationContext(),
					PushConstants.LOGIN_TYPE_API_KEY,
					Utils.getMetaValue(IndexActivity.this, "push_api_key"));

			// Push: �������ڵ���λ�����ͣ����Դ�֧�ֵ���λ�õ����͵Ŀ���
			PushManager.enableLbs(getApplicationContext());
		}
		Log.d("gs_dm:", "gs_" + global.read("gs_dm"));
		List<String> tags = Utils.getTagsList("gs_" + global.read("gs_dm"));
		PushManager.setTags(getApplicationContext(), tags);
	}
	

	setContentView(R.layout.index);
	findview();
	getTotal();
	// LayoutInflater.from(this).inflate(R.layout.activity_index,
	// tabHost.getTabContentView(), true);

}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:39,代码来源:IndexActivity.java

示例13: onStart

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@Override
protected void onStart()
{
    super.onStart();

    PushManager.startWork(getApplicationContext(),
            PushConstants.LOGIN_TYPE_API_KEY, API_KEY);

}
 
开发者ID:steven2947,项目名称:NeXT_pyp,代码行数:10,代码来源:MainActivity.java

示例14: onStart

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@Override
protected void onStart() {
	super.onStart();

	PushManager.startWork(getApplicationContext(),
			PushConstants.LOGIN_TYPE_API_KEY, API_KEY);

}
 
开发者ID:steven2947,项目名称:NeXT_pyp,代码行数:9,代码来源:MainActivity.java

示例15: run

import com.baidu.android.pushservice.PushConstants; //导入依赖的package包/类
@SuppressLint("WorldReadableFiles")
	@Override
	public void run() {
		//确定已复制数据库
		MyDatabase myDB = new MyDatabase(this);
		myDB.closeDB();
		
//		setSP.setTravelFirstShow(true);
		try {
			if (HttpUtil.isNetworkConnected(this)) {
				// 绑定百度云推送
				PushManager
						.startWork(this.getApplicationContext(),
								PushConstants.LOGIN_TYPE_API_KEY,
								MyApp.API_KEY);
			}
			//移动历史离线文件到SD卡
			updateHisOfflineFile();
			
			//初始化抢票监控状态
			String strMFilesPath = MyApp.getInstance().getPathBaseRoot(StoreValue.MONITOR_INFOS_FILE);
			@SuppressWarnings("unchecked")
			List<MonitorInfo> lstMInfos = (List<MonitorInfo>) PersistentUtil.readObject(strMFilesPath);
			if (lstMInfos != null && lstMInfos.size() != 0){
				for (MonitorInfo mInfo : lstMInfos) {
					mInfo.setRunning(false);
					mInfo.setStatus(BgdService2.STATUS_STOPED);
				}
				PersistentUtil.writeObject(lstMInfos, strMFilesPath);
			}
			
			Thread.sleep(1000);
			//检查是否是第一次登录
			if (setSP.isFirstUse()){
				startActivity(new Intent(WelcomeAty.this,
						LoginAty.class));
			}else{
				launtchDefaultAty();
			}
			finish();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:45,代码来源:WelcomeAty.java


注:本文中的com.baidu.android.pushservice.PushConstants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。