update:2019.04.22
fix:增加绑定确认 add:
This commit is contained in:
@@ -62,6 +62,7 @@ import static com.info.sn.jpush.TagAliasOperatorHelper.TagAliasBean;
|
||||
import static com.info.sn.jpush.TagAliasOperatorHelper.sequence;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
public static final String REFRESHACTION = BuildConfig.APPLICATION_ID + ".REFRESH";
|
||||
public static boolean isForeground = false;
|
||||
private ImageView imageView, exit;
|
||||
private TextView tv_note, tv_devsn, tv_username, tv_school, tv_grade, tv_version;
|
||||
@@ -70,6 +71,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
private int DeviceInfo;
|
||||
private long mExitTime;
|
||||
|
||||
private RefreshReceiver mRefreshReceiver;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -82,6 +85,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
pm.setApplicationEnabledSetting("com.info.sn", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||
requestPermission();
|
||||
registerMessageReceiver(); // used for receive msg
|
||||
registerRefreshReceiver();
|
||||
String rid = JPushInterface.getRegistrationID(getApplicationContext());
|
||||
if (!rid.isEmpty()) {
|
||||
ToastUtil.debugShow("RegId:" + rid);
|
||||
@@ -98,6 +102,23 @@ public class MainActivity extends AppCompatActivity {
|
||||
startService(new Intent(MainActivity.this, MyDownloadService.class));
|
||||
}
|
||||
|
||||
public void registerRefreshReceiver() {
|
||||
mRefreshReceiver = new RefreshReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(REFRESHACTION);
|
||||
registerReceiver(mRefreshReceiver, filter);
|
||||
}
|
||||
|
||||
public class RefreshReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (REFRESHACTION.equals(intent.getAction())) {
|
||||
HTTPInterface.checkDevicesInfo(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tv_note = findViewById(R.id.tv_note);
|
||||
imageView = findViewById(R.id.imageView);
|
||||
@@ -491,7 +512,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
//for receive customer msg from jpush server
|
||||
private MessageReceiver mMessageReceiver;
|
||||
public static final String MESSAGE_RECEIVED_ACTION = "com.example.jpushdemo.MESSAGE_RECEIVED_ACTION";
|
||||
public static final String MESSAGE_RECEIVED_ACTION = "com.info.sn.MESSAGE_RECEIVED_ACTION";
|
||||
public static final String KEY_TITLE = "title";
|
||||
public static final String KEY_MESSAGE = "message";
|
||||
public static final String KEY_EXTRAS = "extras";
|
||||
@@ -524,4 +545,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
unregisterReceiver(mRefreshReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user