cn.jpush.android.api.JPushInterface Java Examples

The following examples show how to use cn.jpush.android.api.JPushInterface. 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: PushReceiver.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
private void processCustomMessage(Context context, Bundle bundle) {
    if (MainActivityDrawerLayout.isForeground) {
        String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
        String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
        Intent msgIntent = new Intent(MainActivityDrawerLayout.MESSAGE_RECEIVED_ACTION);
        msgIntent.putExtra(MainActivityDrawerLayout.KEY_MESSAGE, message);
        if (!ExampleUtil.isEmpty(extras)) {
            try {
                JSONObject extraJson = new JSONObject(extras);
                if (null != extraJson && extraJson.length() > 0) {
                    msgIntent.putExtra(MainActivityDrawerLayout.KEY_EXTRAS, extras);
                }
            } catch (JSONException e) {

            }

        }
        context.sendBroadcast(msgIntent);
    }
}
 
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 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 #4
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 #5
Source File: RLPushReceiver.java    From Roid-Library with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    RLNotificationEntity ne = new RLNotificationEntity();
    ne.setId(bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID));
    ne.setTitle(bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE));
    ne.setContent(bundle.getString(JPushInterface.EXTRA_ALERT));
    ne.setExtra(bundle.getString(JPushInterface.EXTRA_EXTRA));
    if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
        // TODO
    } else if (JPushInterface.ACTION_UNREGISTER.equals(intent.getAction())) {
        // TODO
    } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
        // String msg=bundle.getString(JPushInterface.EXTRA_MESSAGE);
        // TODO
    } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
        // TODO
    } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
        Intent i = new Intent(context, RLNotificationActivity.class);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.putExtra("data", ne);
        context.startActivity(i);
    }
}
 
Example #6
Source File: PushSetActivity.java    From HaiNaBaiChuan with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example #7
Source File: JiGuangReceiver.java    From letv with Apache License 2.0 6 votes vote down vote up
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();
    if (TextUtils.equals(intent.getAction(), JPushInterface.ACTION_MESSAGE_RECEIVED)) {
        String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
        if (!TextUtils.isEmpty(message)) {
            try {
                if (!JSONObject.NULL.equals(new JSONObject(message))) {
                    context.stopService(new Intent(context, LetvPushService.class));
                    Intent serviceIntent = new Intent(context, LetvPushService.class);
                    serviceIntent.putExtra(JPushInterface.EXTRA_MESSAGE, message);
                    context.startService(serviceIntent);
                    if (!TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_MSG_ID))) {
                        JPushInterface.reportNotificationOpened(context, bundle.getString(JPushInterface.EXTRA_MSG_ID));
                    }
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}
 
Example #8
Source File: LetvPushService.java    From letv with Apache License 2.0 6 votes vote down vote up
public int onStartCommand(Intent intent, int flags, int startId) {
    LogInfo.log("push", "start query push");
    if (intent == null || !(intent.getStringExtra(JPushInterface.EXTRA_MESSAGE) instanceof String)) {
        this.mPushFrom = 0;
        this.mDataIsFromNormal = true;
    } else {
        this.mPushFrom = 1;
        this.mThirdPushData = intent.getStringExtra(JPushInterface.EXTRA_MESSAGE);
    }
    new Thread(this) {
        final /* synthetic */ LetvPushService this$0;

        {
            if (HotFix.PREVENT_VERIFY) {
                System.out.println(VerifyLoad.class);
            }
            this.this$0 = this$0;
        }

        public void run() {
            this.this$0.fetchData();
        }
    }.start();
    return super.onStartCommand(intent, flags, startId);
}
 
Example #9
Source File: JPushBroadcastReceiver.java    From ans-android-sdk with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    mContext = context;
    Bundle bundle = intent.getExtras();
    if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
        String regId = bundle.getString(JPushInterface.EXTRA_REGISTRATION_ID);
        Log.d(TAG, "接收Registration Id: " + regId);
        //易观打开推送接口
        AnalysysAgent.setPushID(context, PushProvider.JPUSH, regId);
    } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
        int notifactionId = bundle.getInt(JPushInterface.EXTRA_NOTIFICATION_ID);
        Log.d(TAG, "接收到推送下来的通知的ID: " + notifactionId);
        //接收到Push的通知
        AnalysysAgent.trackCampaign(context, bundle.getString(JPushInterface.EXTRA_EXTRA),
                false);
    } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
        Log.d(TAG, "用户点击打开了通知");
        //易观添加活动推广接口,点击了Push推下来的通知
        AnalysysAgent.trackCampaign(context, bundle.getString(JPushInterface.EXTRA_EXTRA),
                true, listener);
    }
}
 
Example #10
Source File: ContactFragment.java    From Social with Apache License 2.0 6 votes vote down vote up
private void handleAutoLogin(Message msg){
    String result = msg.obj.toString();
    Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
    LoginRoot  root = gson.fromJson(result, LoginRoot.class);

    if (root == null){
        Toast.makeText(getActivity(), "服务器繁忙,请重试", Toast.LENGTH_LONG).show();
        return;
    }

    if (root.seccess){
        getFriendList();
    }

    //登录成功后为每个用户设置别名:username
    JPushInterface.setAlias(getActivity(), root.user.username, new TagAliasCallback() {
        @Override
        public void gotResult(int i, String s, Set<String> set) {

        }
    });

}
 
Example #11
Source File: LoginFragment.java    From Social with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View view) {
    int id = view.getId();
    switch (id){
        case R.id.id_login_fg_btn_regist:
            //Intent intent = new Intent(getActivity(), RegistActivity.class);
            Intent intent = new Intent(getActivity(), RegistFirstAcrivity.class);
            startActivity(intent);
            break;
        case R.id.id_login_fg_btn_login:
            username = et_username.getText().toString();
            password = et_password.getText().toString();
            Log.d("LoginFragment", "RegistrationID = " + JPushInterface.getRegistrationID(getActivity()));
            login();
            break;
        case R.id.id_login_fg_iv_qq_login:
            mTencent.login(getActivity(),"all",loginListener);
            break;
        default:
            break;
    }
}
 
Example #12
Source File: TestActivity.java    From iMoney with Apache License 2.0 6 votes vote down vote up
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView tv = new TextView(this);
    tv.setText("用户自定义打开的Activity");
    Intent intent = getIntent();
    if (null != intent) {
        Bundle bundle = getIntent().getExtras();
        String title = null;
        String content = null;
        if (bundle != null) {
            title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
            content = bundle.getString(JPushInterface.EXTRA_ALERT);
        }
        tv.setText("Title : " + title + "  " + "Content : " + content);
    }
    addContentView(tv, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
}
 
Example #13
Source File: PushManager.java    From smart-farmer-android with Apache License 2.0 6 votes vote down vote up
public static void unregister(Context context) {
    if (context == null)
        return;
    if (RomUtil.rom() == PhoneTarget.EMUI) {
        HWReceiver.clearPushListener();
        com.huawei.android.pushagent.api.PushManager.deregisterToken(context, getToken(context).getToken());
        return;

    }
    if (RomUtil.rom() == PhoneTarget.MIUI) {
        MiMessageReceiver.clearPushListener();
        MiPushClient.unregisterPush(context);
        return;
    }

    if (RomUtil.rom() == PhoneTarget.JPUSH) {
        JPushReceiver.clearPushListener();
        JPushInterface.stopPush(context);
        return;
    }
}
 
Example #14
Source File: MyReceiver.java    From iMoney with Apache License 2.0 6 votes vote down vote up
/**
 * send msg to MainActivity
 *
 * @param context
 * @param bundle
 */
private void processCustomMessage(Context context, Bundle bundle) {
    String message = bundle.getString(JPushInterface.EXTRA_MESSAGE);
    String extras = bundle.getString(JPushInterface.EXTRA_EXTRA);
    Intent msgIntent = new Intent(MESSAGE_RECEIVED_ACTION);
    msgIntent.putExtra(KEY_MESSAGE, message);
    if (!ExampleUtil.isEmpty(extras)) {
        try {
            JSONObject extraJson = new JSONObject(extras);
            if (extraJson.length() > 0) {
                msgIntent.putExtra(KEY_EXTRAS, extras);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    LocalBroadcastManager.getInstance(context).sendBroadcast(msgIntent);
}
 
Example #15
Source File: PushManager.java    From smart-farmer-android with Apache License 2.0 6 votes vote down vote up
/**
 * 获取唯一的token
 *
 * @param context
 * @return
 */
public static TokenModel getToken(Context context) {
    if (context == null)
        return null;
    TokenModel result = new TokenModel();
    result.setTarget(RomUtil.rom());
    if (RomUtil.rom() == PhoneTarget.EMUI) {
        result.setToken(HWReceiver.getmToken());
    }
    if (RomUtil.rom() == PhoneTarget.MIUI) {
        result.setToken(MiPushClient.getRegId(context));
    }

    if (RomUtil.rom() == PhoneTarget.JPUSH) {
        result.setToken(JPushInterface.getRegistrationID(context));
    }
    return result;

}
 
Example #16
Source File: ModifyUserDataActivity.java    From Social with Apache License 2.0 6 votes vote down vote up
private void handleAutoLogin(Message msg){
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setTicker("自动登录");
    builder.setContentTitle("已自动登录");
    builder.setContentText("请重新操作...");
    builder.setSmallIcon(R.mipmap.logo);
    builder.setAutoCancel(true);
    NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(4, builder.build());

    String result = msg.obj.toString();
    Log.d("Setting", result);
    Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
    LoginRoot root = gson.fromJson(result, LoginRoot.class);
    JPushInterface.setAlias(this, root.user.username, new TagAliasCallback() {
        @Override
        public void gotResult(int i, String s, Set<String> set) {

        }
    });

}
 
Example #17
Source File: JPushManager.java    From AndroidPush with Apache License 2.0 5 votes vote down vote up
@Override
public void pause(Context context) {
    if (!JPushInterface.isPushStopped(context)) {
        JPushInterface.stopPush(context);
        if (JPushReceiver.getPushInterface() != null) {
            JPushReceiver.getPushInterface().onPaused(context);
        }
    }
}
 
Example #18
Source File: JPushReceiver.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
private static String printBundle(Bundle bundle) {
    StringBuilder sb = new StringBuilder();
    for (String key : bundle.keySet()) {
        if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
            sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
        } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
            sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
        } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
            if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
                Log.i(TAG, "This message has no Extra data");
                continue;
            }

            try {
                JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
                Iterator<String> it = json.keys();

                while (it.hasNext()) {
                    String myKey = it.next().toString();
                    sb.append("\nkey:" + key + ", value: [" +
                            myKey + " - " + json.optString(myKey) + "]");
                }
            } catch (JSONException e) {
                Log.e(TAG, "Get message extra JSON error!");
            }

        } else {
            sb.append("\nkey:" + key + ", value:" + bundle.getString(key));
        }
    }
    return sb.toString();
}
 
Example #19
Source File: TestActivity.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView tv = new TextView(this);
    tv.setText("用户自定义打开的Activity");
    Intent intent = getIntent();
    if (null != intent) {
     Bundle bundle = getIntent().getExtras();
     String title = bundle.getString(JPushInterface.EXTRA_NOTIFICATION_TITLE);
     String content = bundle.getString(JPushInterface.EXTRA_ALERT);
     tv.setText("Title : " + title + "  " + "Content : " + content);
    }
    addContentView(tv, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}
 
Example #20
Source File: JPushManager.java    From AndroidPush with Apache License 2.0 5 votes vote down vote up
@Override
public TokenModel getToken(Context context) {
    if (context == null)
        return null;
    TokenModel result = new TokenModel();
    result.setTarget(RomUtil.rom());
    result.setToken(JPushInterface.getRegistrationID(context));
    return result;
}
 
Example #21
Source File: JPushManager.java    From AndroidPush with Apache License 2.0 5 votes vote down vote up
@Override
public void register(Context context, boolean debug, PushInterface pushInterface) {
    if (pushInterface != null) {
        JPushReceiver.registerInterface(pushInterface);
    }
    JPushInterface.init(context);
    JPushInterface.setDebugMode(debug);
}
 
Example #22
Source File: GosUserLoginActivity.java    From gokit-android with MIT License 5 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();

	JPushInterface.onResume(this);
	autoLogin();
}
 
Example #23
Source File: PushSetActivity.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
/**
 *设置通知提示方式 - 基础属性
 */
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();
}
 
Example #24
Source File: PushSetActivity.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
/**
 *设置通知栏样式 - 定义通知栏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();
}
 
Example #25
Source File: MyReceiver.java    From iMoney with Apache License 2.0 5 votes vote down vote up
/**
 * 打印所有的 intent extra 数据
 *
 * @param bundle
 * @return
 */
private static String printBundle(Bundle bundle) {
    StringBuilder sb = new StringBuilder();
    for (String key : bundle.keySet()) {
        if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
            sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
        } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
            sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
        } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
            if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
                LogUtil.i(TAG, "This message has no Extra data");
                continue;
            }

            try {
                JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
                Iterator<String> it = json.keys();

                while (it.hasNext()) {
                    String myKey = it.next();
                    sb.append("\nkey:" + key + ", value: [" +
                            myKey + " - " + json.optString(myKey) + "]");
                }
            } catch (JSONException e) {
                LogUtil.e(TAG, "Get message extra JSON error!");
            }

        } else {
            sb.append("\nkey:" + key + ", value:" + bundle.getString(key));
        }
    }
    return sb.toString();
}
 
Example #26
Source File: PushManager.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
/**
 * 设置别名
 * <p>
 * 华为
 * <p>
 * 不支持alias的写法,所以只能用tag,tag只能放map,所以alias作为value,key为name
 * ==========
 * 极光 别名
 * <p>
 * "" (空字符串)表示取消之前的设置。
 * 每次调用设置有效的别名,覆盖之前的设置。
 * 有效的别名组成:字母(区分大小写)、数字、下划线、汉字、特殊字符(v2.1.6支持)@!#$&*+=.|。
 * 限制:alias 命名长度限制为 40 字节。(判断长度需采用UTF-8编码)
 * ==========
 * 小米 别名
 * <p>
 * 一个RegId可以被设置多个别名,如果设置的别名已经存在,会覆盖掉之前的别名。
 */
public static void setAlias(final Context context, String alias) {
    if (TextUtils.isEmpty(alias))
        return;
    if (RomUtil.rom() == PhoneTarget.EMUI) {
        Map<String, String> tag = new HashMap<>();
        tag.put("name", alias);
        com.huawei.android.pushagent.api.PushManager.setTags(context, tag);
        return;

    }
    if (RomUtil.rom() == PhoneTarget.MIUI) {
        MiPushClient.setAlias(context, alias, null);

        return;
    }

    if (RomUtil.rom() == PhoneTarget.JPUSH) {
        JPushInterface.setAlias(context, alias, new TagAliasCallback() {
            @Override
            public void gotResult(int i, String s, Set<String> set) {
                if (i == 0) { // 这里极光规定0代表成功
                    if (JPushReceiver.getPushListener() != null) {
                        JPushReceiver.getPushListener().onAlias(context, s);
                    }
                }
            }
        });
    }

}
 
Example #27
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 #28
Source File: BaseApplication.java    From Android-IM with Apache License 2.0 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        baseApplication = this;
        MultiDex.install(this);
        sharedPrefHelper = SharedPrefHelper.getInstance();
        sharedPrefHelper.setRoaming(true);
        //开启极光调试
        JPushInterface.setDebugMode(true);
        mContext = BaseApplication.this;
        //实例化极光推送
        JPushInterface.init(mContext);
        //实例化极光IM,并自动同步聊天记录
        JMessageClient.init(getApplicationContext(), true);
        JMessageClient.setDebugMode(true);
        //初始化极光sms
//        SMSSDK.getInstance().initSdk(mContext);
        //初始化数据库
        setupDatabase();
        //通知管理,通知栏开启,其他关闭
        JMessageClient.setNotificationFlag(FLAG_NOTIFY_SILENCE);
        //初始化utils
        Utils.init(this);
        //推送状态
        initJPush2();
        //初始化统计
        JAnalyticsInterface.init(mContext);
        JAnalyticsInterface.setDebugMode(true);

    }
 
Example #29
Source File: JPushReReceiver.java    From phphub-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    Bundle bundle = intent.getExtras();

    if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
        boolean openedOtherActivity = handleOpenNotification(context, bundle);

        if (!openedOtherActivity) {
            Intent i = new Intent();
            i.setClass(context, MainActivity.class);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
            context.startActivity(i);
        }
    }
}
 
Example #30
Source File: JPushReceiver.java    From AndroidPush with Apache License 2.0 5 votes vote down vote up
private static String printBundle(Bundle bundle) {
    StringBuilder sb = new StringBuilder();
    for (String key : bundle.keySet()) {
        if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
            sb.append("\nkey:").append(key).append(", value:").append(bundle.getInt(key));
        } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
            sb.append("\nkey:").append(key).append(", value:").append(bundle.getBoolean(key));
        } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
            if (bundle.getString(JPushInterface.EXTRA_EXTRA).isEmpty()) {
                L.i("This message has no Extra data");
                continue;
            }

            try {
                JSONObject json = new JSONObject(bundle.getString(JPushInterface.EXTRA_EXTRA));
                Iterator<String> it = json.keys();

                while (it.hasNext()) {
                    String myKey = it.next().toString();
                    sb.append("\nkey:").append(key + ", value: [" +
                            myKey).append(" - ").append(json.optString(myKey) + "]");
                }
            } catch (JSONException e) {
                L.i("Get message extra JSON error!");
            }

        } else {
            sb.append("\nkey:").append(key).append(", value:" + bundle.getString(key));
        }
    }
    return sb.toString();
}