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


Java PushManager类代码示例

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


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

示例1: onReceive

import com.baidu.android.pushservice.PushManager; //导入依赖的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.PushManager; //导入依赖的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: quit

import com.baidu.android.pushservice.PushManager; //导入依赖的package包/类
public void quit() {
	MobclickAgent.onKillProcess(this);
	MyApp myApp = ((MyApp)getApplication());
	L.i("isAntiTheftServiceStarted:" + myApp.isAntiTheftServiceStarted);
	L.i("isBgdService2Started:" + myApp.isBgdService2Started);
	if (myApp.isAntiTheftServiceStarted || myApp.isBgdService2Started){
		MainActivity.this.finish();
	}else{
		Intent startMain = new Intent(Intent.ACTION_MAIN);
		startMain.addCategory(Intent.CATEGORY_HOME);
		startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
		startActivity(startMain);
		System.exit(0);
	}
	//确认是否在退出后取消接收聊天信息
	SettingSPUtil setSP = MyApp.getInstance().getSettingSPUtil();
	if (!setSP.isChatReceiveMsgAlways()){
		PushManager.stopWork(getApplicationContext());
	}
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:21,代码来源:MainActivity.java

示例4: onCreate

import com.baidu.android.pushservice.PushManager; //导入依赖的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

示例5: deleteTags

import com.baidu.android.pushservice.PushManager; //导入依赖的package包/类
private void deleteTags() {
    LinearLayout layout = new LinearLayout(PushDemoActivity.this);
    layout.setOrientation(LinearLayout.VERTICAL);

    final EditText textviewGid = new EditText(PushDemoActivity.this);
    textviewGid.setHint("请输入多个标签,以英文逗号隔开");
    layout.addView(textviewGid);

    AlertDialog.Builder builder = new AlertDialog.Builder(
            PushDemoActivity.this);
    builder.setView(layout);
    builder.setPositiveButton("删除标签",
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // Push: 删除tag调用方式
                    List<String> tags = Utils.getTagsList(textviewGid
                            .getText().toString());
                    PushManager.delTags(getApplicationContext(), tags);
                }
            });
    builder.show();
}
 
开发者ID:leonardo-hammer,项目名称:H5P.Plugins.push.baidu,代码行数:25,代码来源:PushDemoActivity.java

示例6: setTags

import com.baidu.android.pushservice.PushManager; //导入依赖的package包/类
private void setTags() {
    LinearLayout layout = new LinearLayout(PushDemoActivity.this);
    layout.setOrientation(LinearLayout.VERTICAL);

    final EditText textviewGid = new EditText(PushDemoActivity.this);
    textviewGid.setHint("请输入多个标签,以英文逗号隔开");
    layout.addView(textviewGid);

    AlertDialog.Builder builder = new AlertDialog.Builder(
            PushDemoActivity.this);
    builder.setView(layout);
    builder.setPositiveButton("设置标签",
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // Push: 设置tag调用方式
                    List<String> tags = Utils.getTagsList(textviewGid
                            .getText().toString());
                    PushManager.setTags(getApplicationContext(), tags);
                }

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

示例7: onNewIntent

import com.baidu.android.pushservice.PushManager; //导入依赖的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

示例8: deleteTags

import com.baidu.android.pushservice.PushManager; //导入依赖的package包/类
private void deleteTags() {
    LinearLayout layout = new LinearLayout(PushDemoActivity.this);
    layout.setOrientation(LinearLayout.VERTICAL);

    final EditText textviewGid = new EditText(PushDemoActivity.this);
    textviewGid.setHint("请输入多个标签,以英文逗号隔开");
    layout.addView(textviewGid);

    AlertDialog.Builder builder = new AlertDialog.Builder(
            PushDemoActivity.this);
    builder.setView(layout);
    builder.setPositiveButton("删除标签",
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    // Push: 删除tag调用方式
                    List<String> tags = Utils.getTagsList(textviewGid
                            .getText().toString());
                    PushManager.delTags(getApplicationContext(), tags);
                }
            });
    builder.show();
}
 
开发者ID:mnhkahn,项目名称:cInterphone,代码行数:24,代码来源:PushDemoActivity.java

示例9: setTags

import com.baidu.android.pushservice.PushManager; //导入依赖的package包/类
private void setTags() {
    LinearLayout layout = new LinearLayout(PushDemoActivity.this);
    layout.setOrientation(LinearLayout.VERTICAL);

    final EditText textviewGid = new EditText(PushDemoActivity.this);
    textviewGid.setHint("请输入多个标签,以英文逗号隔开");
    layout.addView(textviewGid);

    AlertDialog.Builder builder = new AlertDialog.Builder(
            PushDemoActivity.this);
    builder.setView(layout);
    builder.setPositiveButton("设置标签",
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    // Push: 设置tag调用方式
                    List<String> tags = Utils.getTagsList(textviewGid
                            .getText().toString());
                    PushManager.setTags(getApplicationContext(), tags);
                }

            });
    builder.show();
}
 
开发者ID:mnhkahn,项目名称:cInterphone,代码行数:25,代码来源:PushDemoActivity.java

示例10: updateTags

import com.baidu.android.pushservice.PushManager; //导入依赖的package包/类
/**
 * 更新baiduPush服务端的 tags
 * @param currentTags 当前服务端的tags
 */
public void updateTags(Context context , List<String> currentTags) {
	List<String> newTags = getTagsList();
	//向服务器更新
	if(currentTags==null||currentTags.size()==0){
		//没有tag直接设置
		if(newTags.size()!=0){
			PushManager.setTags(context,newTags);
		}
	}else{
		//生成需要添加的tag列表和需要删除的tag列表
		List<String> rmTags = currentTags; //先假设服务器中的tag都需要删除
		List<String> addTags = new ArrayList<String>();
		for (String tag : newTags) {
			if(rmTags.contains(tag)){
				//服务器已经包含此tag
				rmTags.remove(tag); //仍需要此tag所以将其从此删除列表中移除
			}else{
				addTags.add(tag);
			}
		}
		if(rmTags.size()!=0){
			PushManager.delTags(context,rmTags);
		}
		if(addTags.size()!=0){
			PushManager.setTags(context,addTags);
		}
	}
	//查看当前tag--log输出
	PushManager.listTags(context);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:35,代码来源:BaiduPushTagsHelper.java

示例11: bDPush

import com.baidu.android.pushservice.PushManager; //导入依赖的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

示例12: bDPush

import com.baidu.android.pushservice.PushManager; //导入依赖的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

示例13: startWork

import com.baidu.android.pushservice.PushManager; //导入依赖的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

示例14: initWithApiKey

import com.baidu.android.pushservice.PushManager; //导入依赖的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

示例15: init

import com.baidu.android.pushservice.PushManager; //导入依赖的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


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