本文整理汇总了Java中com.baidu.android.pushservice.PushManager.startWork方法的典型用法代码示例。如果您正苦于以下问题:Java PushManager.startWork方法的具体用法?Java PushManager.startWork怎么用?Java PushManager.startWork使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.baidu.android.pushservice.PushManager
的用法示例。
在下文中一共展示了PushManager.startWork方法的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);
}
}
}
}
示例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);
}
}
示例3: 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();
}
示例4: 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();
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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"));
}
示例9: 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();
}
示例10: onCreate
import com.baidu.android.pushservice.PushManager; //导入方法依赖的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);
}
示例11: onStart
import com.baidu.android.pushservice.PushManager; //导入方法依赖的package包/类
@Override
protected void onStart()
{
super.onStart();
PushManager.startWork(getApplicationContext(),
PushConstants.LOGIN_TYPE_API_KEY, API_KEY);
}
示例12: onStart
import com.baidu.android.pushservice.PushManager; //导入方法依赖的package包/类
@Override
protected void onStart() {
super.onStart();
PushManager.startWork(getApplicationContext(),
PushConstants.LOGIN_TYPE_API_KEY, API_KEY);
}
示例13: run
import com.baidu.android.pushservice.PushManager; //导入方法依赖的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();
}
}
示例14: onCreate
import com.baidu.android.pushservice.PushManager; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.logStringCache = Utils.getLogText(getApplicationContext());
Resources resource = this.getResources();
String pkgName = this.getPackageName();
setContentView(resource.getIdentifier("main", "layout", pkgName));
akBtnId = resource.getIdentifier("btn_initAK", "id", pkgName);
initBtnId = resource.getIdentifier("btn_init", "id", pkgName);
richBtnId = resource.getIdentifier("btn_rich", "id", pkgName);
setTagBtnId = resource.getIdentifier("btn_setTags", "id", pkgName);
delTagBtnId = resource.getIdentifier("btn_delTags", "id", pkgName);
clearLogBtnId = resource.getIdentifier("btn_clear_log", "id", pkgName);
initWithApiKey = (Button) findViewById(akBtnId);
initButton = (Button) findViewById(initBtnId);
displayRichMedia = (Button) findViewById(richBtnId);
setTags = (Button) findViewById(setTagBtnId);
delTags = (Button) findViewById(delTagBtnId);
clearLog = (Button) findViewById(clearLogBtnId);
logText = (TextView) findViewById(resource.getIdentifier("text_log",
"id", pkgName));
scrollView = (ScrollView) findViewById(resource.getIdentifier(
"stroll_text", "id", pkgName));
initWithApiKey.setOnClickListener(this);
initButton.setOnClickListener(this);
setTags.setOnClickListener(this);
delTags.setOnClickListener(this);
displayRichMedia.setOnClickListener(this);
clearLog.setOnClickListener(this);
// Push: 以apikey的方式登录,一般放在主Activity的onCreate中。
// 这里把apikey存放于manifest文件中,只是一种存放方式,
// 您可以用自定义常量等其它方式实现,来替换参数中的Utils.getMetaValue(PushDemoActivity.this,
// "api_key")
// 通过share preference实现的绑定标志开关,如果已经成功绑定,就取消这次绑定
if (!Utils.hasBind(getApplicationContext())) {
PushManager.startWork(getApplicationContext(),
PushConstants.LOGIN_TYPE_API_KEY,
Utils.getMetaValue(PushDemoActivity.this, "api_key"));
// Push: 如果想基于地理位置推送,可以打开支持地理位置的推送的开关
// PushManager.enableLbs(getApplicationContext());
}
// Push: 设置自定义的通知样式,具体API介绍见用户手册,如果想使用系统默认的可以不加这段代码
// 请在通知推送界面中,高级设置->通知栏样式->自定义样式,选中并且填写值:1,
// 与下方代码中 PushManager.setNotificationBuilder(this, 1, cBuilder)中的第二个参数对应
CustomPushNotificationBuilder cBuilder = new CustomPushNotificationBuilder(
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(this.getApplicationInfo().icon);
cBuilder.setLayoutDrawable(resource.getIdentifier(
"simple_notification_icon", "drawable", pkgName));
PushManager.setNotificationBuilder(this, 1, cBuilder);
}
示例15: initWithApiKey
import com.baidu.android.pushservice.PushManager; //导入方法依赖的package包/类
private void initWithApiKey() {
// Push: 无账号初始化,用api key绑定
PushManager.startWork(getApplicationContext(),
PushConstants.LOGIN_TYPE_API_KEY,
Utils.getMetaValue(PushDemoActivity.this, "api_key"));
}