Beispiel #1
0
 public void init(Context context) {
   JPushInterface.setDebugMode(true);
   JPushInterface.init(context);
   registerMessageReceiver(context);
   client = new ApacheHttpClient(new HttpConfig(context));
   Core.context = context;
 }
Beispiel #2
0
 @Override
 public void onCreate() {
   super.onCreate();
   BaiduManager.init(this);
   JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志
   JPushInterface.init(this); // 初始化 JPush
 }
Beispiel #3
0
  @Override
  public void onCreate() {
    Log.d(TAG, "onCreate");
    super.onCreate();

    JPushInterface.setDebugMode(true); // 设置开启日志,发布时请关闭日志
    JPushInterface.init(this); // 初始化 JPush
  }
Beispiel #4
0
  @Override
  public void onCreate() {
    super.onCreate();

    sContext = getApplicationContext();

    instance = this;

    // 初始化 jpush
    JPushInterface.setDebugMode(true);
    JPushInterface.init(this);
  }
Beispiel #5
0
  @Override
  public void onCreate() {
    super.onCreate();
    JPushInterface.setDebugMode(true);
    JPushInterface.init(this);
    RongIM.init(this, "pvxdm17jx5lmr", R.drawable.mineral_logo);
    if (SettingUtil.getInstance(getApplicationContext())
        .getValue(SettingUtil.KEY_ACCEPT_PUSH_NOTIFICATION, true)) {
      JPushInterface.resumePush(getApplicationContext());

    } else {
      JPushInterface.stopPush(getApplicationContext());
    }
  }
  protected void pluginInitialize() {
    Log.i(TAG, "pluginInitialize");

    JMessageClient.init(cordova.getActivity().getApplicationContext());
    JMessageClient.registerEventReceiver(this);
    JPushInterface.init(this.cordova.getActivity().getApplicationContext());
  }
Beispiel #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test_activity);

    gcmRegId = GCMRegistrar.getRegistrationId(this);
    jpushRegId = JPushInterface.getRegistrationID(this);

    tv = (TextView) findViewById(R.id.test_tv);

    tv.setText(
        "GCMregId:"
            + gcmRegId
            + LINE
            + "jpushRegId:"
            + jpushRegId
            + LINE
            + "string.xml server:"
            + getString(R.string.server_address)
            + LINE
            + "Server IP:"
            + Constants.hostUrl
            + LINE
            + "ETS Server:"
            + Constants.ETShostUrl);
  }
Beispiel #8
0
        @SuppressWarnings("unchecked")
        @Override
        public void handleMessage(android.os.Message msg) {
          super.handleMessage(msg);
          switch (msg.what) {
            case MSG_SET_ALIAS:
              JPushInterface.setAliasAndTags(
                  getApplicationContext(), (String) msg.obj, null, mAliasCallback);
              break;

            case MSG_SET_TAGS:
              JPushInterface.setAliasAndTags(
                  getApplicationContext(), null, (Set<String>) msg.obj, mTagsCallback);
              break;
          }
        }
  void setTags(JSONArray data, CallbackContext callbackContext) {

    HashSet<String> tags = null;
    try {
      String tagStr;
      if (data == null) {
        // tags=null;
      } else if (data.length() == 0) {
        tags = new HashSet<String>();
      } else {
        tagStr = data.getString(0);
        String[] tagArray = tagStr.split(",");
        for (String tag : tagArray) {
          if (tags == null) {
            tags = new HashSet<String>();
          }
          tags.add(tag);
        }
      }
      // Set<String> validTags = JPushInterface.filterValidTags(tags);
      JPushInterface.setTags(
          this.cordova.getActivity().getApplicationContext(), tags, mTagWithAliasCallback);
      callbackContext.success();
    } catch (JSONException e) {
      e.printStackTrace();
      callbackContext.error("Error reading tags JSON");
    }
  }
 void isPushStopped(JSONArray data, CallbackContext callbackContext) {
   boolean isStopped =
       JPushInterface.isPushStopped(this.cordova.getActivity().getApplicationContext());
   if (isStopped) {
     callbackContext.success(1);
   } else {
     callbackContext.success(0);
   }
 }
 void reportNotificationOpened(JSONArray data, CallbackContext callbackContext) {
   try {
     String msgID;
     msgID = data.getString(0);
     JPushInterface.reportNotificationOpened(this.cordova.getActivity(), msgID);
   } catch (JSONException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 /** 设置通知提示方式 - 基础属性 */
 private void setStyleBasic() {
   BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(PushSetActivity.this);
   builder.statusBarDrawable = R.drawable.ic_launcher;
   builder.notificationFlags = Notification.FLAG_AUTO_CANCEL; // 设置为点击后自动消失
   builder.notificationDefaults =
       Notification
           .DEFAULT_SOUND; // 设置为铃声( Notification.DEFAULT_SOUND)或者震动( Notification.DEFAULT_VIBRATE)
   JPushInterface.setPushNotificationBuilder(1, builder);
   Toast.makeText(PushSetActivity.this, "Basic Builder - 1", Toast.LENGTH_SHORT).show();
 }
        @Override
        public void handleMessage(android.os.Message msg) {
          super.handleMessage(msg);
          switch (msg.what) {
            case MSG_SET_ALIAS:
              Log.d(TAG, "Set alias in handler.");
              JPushInterface.setAliasAndTags(
                  getApplicationContext(), (String) msg.obj, null, mAliasCallback);
              break;

            case MSG_SET_TAGS:
              Log.d(TAG, "Set tags in handler.");
              JPushInterface.setAliasAndTags(
                  getApplicationContext(), null, (Set<String>) msg.obj, mTagsCallback);
              break;

            default:
              Log.i(TAG, "Unhandled msg - " + msg.what);
          }
        }
 void setAlias(JSONArray data, CallbackContext callbackContext) {
   try {
     String alias = data.getString(0);
     JPushInterface.setAlias(
         this.cordova.getActivity().getApplicationContext(), alias, mTagWithAliasCallback);
     callbackContext.success();
   } catch (JSONException e) {
     e.printStackTrace();
     callbackContext.error("Error reading alias JSON");
   }
 }
 void setBasicPushNotificationBuilder(JSONArray data, CallbackContext callbackContext) {
   BasicPushNotificationBuilder builder =
       new BasicPushNotificationBuilder(this.cordova.getActivity());
   builder.developerArg0 = "Basic builder 1";
   JPushInterface.setPushNotificationBuilder(1, builder);
   JSONObject obj = new JSONObject();
   try {
     obj.put("id", 1);
   } catch (JSONException e) {
     e.printStackTrace();
   }
   // callbackContext.success(obj);
 }
 /** 设置通知栏样式 - 定义通知栏Layout */
 private void setStyleCustom() {
   CustomPushNotificationBuilder builder =
       new CustomPushNotificationBuilder(
           PushSetActivity.this,
           R.layout.customer_notitfication_layout,
           R.id.icon,
           R.id.title,
           R.id.text);
   builder.layoutIconDrawable = R.drawable.ic_launcher;
   builder.developerArg0 = "developerArg2";
   JPushInterface.setPushNotificationBuilder(2, builder);
   Toast.makeText(PushSetActivity.this, "Custom Builder - 2", Toast.LENGTH_SHORT).show();
 }
Beispiel #17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_splash);
    JPushInterface.setDebugMode(true);
    JPushInterface.init(this);

    new Handler()
        .postDelayed(
            new Runnable() {

              @Override
              public void run() {

                Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                SplashActivity.this.startActivity(intent);
                SplashActivity.this.finish();
              }
            },
            SPLASH_DISPLAY_LENGTH);
  }
 public void setTags(long func_handler, Context context, Set<String> tags, long func_ptr) {
   callback_ptr = func_ptr;
   callback_handler = func_handler;
   JPushInterface.setTags(
       context,
       tags,
       new TagAliasCallback() {
         @Override
         public void gotResult(int arg0, String arg1, Set<String> arg2) {
           // TODO Auto-generated method stub
           setAliasAndTagsCallback(callback_handler, arg0, arg1, arg2, callback_ptr);
         }
       });
 }
 void clearNotificationById(JSONArray data, CallbackContext callbackContext) {
   int notificationId = -1;
   try {
     notificationId = data.getInt(0);
   } catch (JSONException e) {
     e.printStackTrace();
     callbackContext.error("error reading id json");
   }
   if (notificationId != -1) {
     JPushInterface.clearNotificationById(this.cordova.getActivity(), notificationId);
   } else {
     callbackContext.error("error id");
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);

    JPushInterface.clearAllNotifications(getApplicationContext());
    JPushHelper jPushHelper = new JPushHelper(null, null);
    jPushHelper.cancelAlias();

    ApiClient.userLogout();

    mBtLogin.setOnClickListener(this);
    btGreenChannel.setOnClickListener(this);
  }
 void setLatestNotificationNum(JSONArray data, CallbackContext callbackContext) {
   int num = -1;
   try {
     num = data.getInt(0);
   } catch (JSONException e) {
     e.printStackTrace();
     callbackContext.error("error reading num json");
   }
   if (num != -1) {
     JPushInterface.setLatestNotificationNumber(
         this.cordova.getActivity().getApplicationContext(), num);
   } else {
     callbackContext.error("error num");
   }
 }
 void setDebugMode(JSONArray data, CallbackContext callbackContext) {
   boolean mode;
   try {
     mode = data.getBoolean(0);
     // if (mode.equals("true")) {
     // 	JPushInterface.setDebugMode(true);
     // } else if (mode.equals("false")) {
     // 	JPushInterface.setDebugMode(false);
     // } else {
     // 	callbackContext.error("error mode");
     // }
     JPushInterface.setDebugMode(mode);
     callbackContext.success();
   } catch (JSONException e) {
   }
 }
Beispiel #23
0
  void setTags(JSONArray data, CallbackContext callbackContext) {

    try {
      HashSet<String> tags = new HashSet<String>();
      for (int i = 0; i < data.length(); i++) {
        tags.add(data.getString(i));
      }
      JPushInterface.setTags(
          this.cordova.getActivity().getApplicationContext(), tags, mTagWithAliasCallback);
      callbackContext.success();

    } catch (JSONException e) {
      e.printStackTrace();
      callbackContext.error("Error reading tags JSON");
    }
  }
 private void doCheckNetTask() {
   User user = SPUtil.getDefaultUser(this, null);
   Map<String, Object> taskParams = new HashMap<String, Object>();
   taskParams.put(Task.FAN_ACTIVITY, HomePageActivity.class.getSimpleName());
   taskParams.put(User.PHONENUMBER, user.getPhoneNumber());
   taskParams.put(User.PASSWORD, user.getPassword());
   taskParams.put(Task.FAN_AUTHO_DEVICE_CODE, JPushInterface.getRegistrationID(this));
   taskParams.put(Task.FAN_AUTHO_SYSTEM_TYPE, Task.FAN_AUTHO_SYSTEM_TYPE_ANDROID);
   if (first_time_login) {
     taskParams.put(Task.FAN_AUTHO_BACK_LOGIN, Task.FAN_AUTHO_BACK_LOGIN_NO);
   } else {
     taskParams.put(Task.FAN_AUTHO_BACK_LOGIN, Task.FAN_AUTHO_BACK_LOGIN_YES);
   }
   Task task = new Task(Task.FAN_AUTHO, taskParams);
   IfanService.addTask(task);
 }
 void setCustomPushNotificationBuilder(JSONArray data, CallbackContext callbackContext) {
   CustomPushNotificationBuilder builder =
       new CustomPushNotificationBuilder(
           this.cordova.getActivity(),
           R.layout.test_notification_layout,
           R.id.icon,
           R.id.title,
           R.id.text);
   builder.developerArg0 = "Custom Builder 1";
   builder.layoutIconDrawable = R.drawable.jpush_notification_icon;
   JPushInterface.setPushNotificationBuilder(2, builder);
   JSONObject obj = new JSONObject();
   try {
     obj.put("id", 2);
   } catch (JSONException e) {
     e.printStackTrace();
   }
   // callbackContext.success(obj);
 }
  void addLocalNotification(JSONArray data, CallbackContext callbackContext) throws JSONException {
    // builderId,content,title,notificaitonID,broadcastTime,extras

    int builderId = data.getInt(0);
    String content = data.getString(1);
    String title = data.getString(2);
    int notificationID = data.getInt(3);
    int broadcastTime = data.getInt(4);
    JSONObject extras = data.getJSONObject(5);

    JPushLocalNotification ln = new JPushLocalNotification();
    ln.setBuilderId(builderId);
    ln.setContent(content);
    ln.setTitle(title);
    ln.setNotificationId(notificationID);
    ln.setBroadcastTime(System.currentTimeMillis() + broadcastTime);

    ln.setExtras(extras.toString());
    JPushInterface.addLocalNotification(this.cordova.getActivity(), ln);
  }
Beispiel #27
0
 @Override
 public void run() {
   JsonRequest<LoginResult> req =
       new JsonRequest<LoginResult>(Constant.SERVER_LOGIN_ADDRESS, LoginResult.class);
   req.setHttpBody(new JsonBody(u));
   final LoginResult r = client.post(req);
   JPushInterface.setAliasAndTags(
       context,
       u.getUsername(),
       null,
       new TagAliasCallback() {
         @Override
         public void gotResult(int i, String s, Set<String> set) {
           if (i == 0) {
             BusProvider.getBus().post(r);
           } else {
             Log.d(Constant.LOG_TAG, "Set alias error!");
           }
         }
       });
 }
  protected void onResume() {
    super.onResume();
    JPushInterface.onResume(this);
    LinkedList<NewsTypeItem> typeItems = NewsTypeItem.getNewsTypeItems(this);
    NewsTypeItemDaoImpl newsTypeItemDao = new NewsTypeItemDaoImpl(new DBHelper(this));
    boolean update =
        (null == newsTypeItemDao.getNewsTypeItems()
            || (typeItems != null
                && newsTypeItemDao.getNewsTypeItems().size() != typeItems.size()));

    if (update
        || !mPreferences.contains(PREF_FIRST_INSERT_IMG_URL)
        || !mPreferences.getBoolean(PREF_FIRST_INSERT_IMG_URL, false)) {
      insertImgUrls();
    }
    if (update
        || !mPreferences.contains(PREF_FIRST_INSERT_NEWS_TYPE)
        || !mPreferences.getBoolean(PREF_FIRST_INSERT_NEWS_TYPE, false)) {
      insertNewsType(newsTypeItemDao, typeItems);
    }
    GoogleApplication.mIsOnlyAndroid = mPreferences.getBoolean(PREF_ONLY_ANDROID, false);
    GoogleApplication.mIsExactBus = mPreferences.getBoolean(PREF_EXACT_BUS, false);
  }
 void setPushTime(JSONArray data, CallbackContext callbackContext) {
   Set<Integer> days = new HashSet<Integer>();
   JSONArray dayArray;
   int startHour = -1;
   int endHour = -1;
   try {
     dayArray = data.getJSONArray(0);
     for (int i = 0; i < dayArray.length(); i++) {
       days.add(dayArray.getInt(i));
     }
   } catch (JSONException e) {
     e.printStackTrace();
     callbackContext.error("error reading days json");
   }
   try {
     startHour = data.getInt(1);
     endHour = data.getInt(2);
   } catch (JSONException e) {
     callbackContext.error("error reading hour json");
   }
   JPushInterface.setPushTime(
       this.cordova.getActivity().getApplicationContext(), days, startHour, endHour);
   callbackContext.success();
 }
 @Override
 protected void onResume() {
   super.onResume();
   JPushInterface.onResume(this);
 }