public void onReceive(Context context, Intent intent) { Log.e("auth failure receiver received"); if (sIsHandling || !PrefUtil.getInstance(context).isLogined()) { return; } sIsHandling = true; PrefUtil.getInstance(context).logoutAccount(); ManageAccountsActivity.deleteDatasInDB(context); Database database = new Database(context); database.close(); // 变换Database,Connect2的标志位(用户判断是否切换了用户) Database.sFlagIndex++; Connect2.sFlagIndex++; // auth failure, don't need to logout. // WowTalkWebServerIF mWeb = WowTalkWebServerIF.getInstance(context); // mWeb.fLogout(); WowTalkVoipIF.getInstance(context).fStopWowTalkService(); Intent loginIntent = new Intent(context, LoginActivity.class); // android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity // context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); loginIntent.putExtra( LoginActivity.EXTRA_PROMPT, context.getString(R.string.account_web_api_auth_failure)); context.startActivity(loginIntent); if (null != StartActivity.instance()) { StartActivity.instance().finish(); } sIsHandling = false; }
private void initView() { lesPersToPost = new ArrayList<LessonPerformance>(); stuPersFromNet = new ArrayList<LessonPerformance>(); mMsgBox = new MessageBox(this); lessonServer = LessonWebServerIF.getInstance(LessonStatusActivity.this); mDBHelper = Database.open(this); preformstrs = getResources().getStringArray(R.array.lesson_performance_names); lvPerformances = (ListView) findViewById(R.id.lv_les_status); findViewById(R.id.title_back).setOnClickListener(this); Button btn = (Button) findViewById(R.id.btn_parent_confirm); btn.setOnClickListener(this); Intent intent = getIntent(); lessonId = intent.getIntExtra(Constants.LESSONID, 0); stuId = intent.getStringExtra(Constants.STUID); isTeacher = intent.getBooleanExtra(FALG, false); if (isTeacher) { btn.setText(R.string.login_retrieve_password_btn); } else { btn.setVisibility(View.GONE); } getStuPerformceById(); }
@Override public int onStartCommand(Intent intent, int flags, int startId) { mWeb = WowTalkWebServerIF.getInstance(this); mMomentWeb = MomentWebServerIF.getInstance(this); mDb = Database.open(this); handleCommand(intent); // We want this service to continue running until it is explicitly // stopped, so return sticky. return START_STICKY; }
private void resetTempGroupName(final String groupChatName) { mMsgBox.showWait(); final GroupChatRoom chatRoom = mDbHelper.fetchGroupChatRoom(mGroupId); if (null == chatRoom) { return; } chatRoom.groupNameLocal = groupChatName; chatRoom.groupNameOriginal = groupChatName; chatRoom.isTemporaryGroup = true; chatRoom.isGroupNameChanged = true; AsyncTaskExecutor.executeShortNetworkTask( new AsyncTask<Void, Integer, Integer>() { @Override protected Integer doInBackground(Void... params) { return WowTalkWebServerIF.getInstance(ModifyTempGroupChatNameActivity.this) .fGroupChat_UpdateInfo(chatRoom); } @Override protected void onPostExecute(Integer result) { mMsgBox.dismissWait(); if (result == ErrorCode.OK) { // update local temp group name Database db = new Database(ModifyTempGroupChatNameActivity.this); db.updateGroupChatRoom(chatRoom); // update the display name of chatmessages db.updateChatMessageDisplayNameWithUser(mGroupId, groupChatName); // setResult Intent data = new Intent(); data.putExtra(EXTRA_GROUP_NAME, groupChatName); setResult(Activity.RESULT_OK, data); finish(); } else { mMsgBox.show(null, getString(R.string.group_chat_title_modify_failure)); // Toast toast = // Toast.makeText(ModifyTempGroupChatNameActivity.this, // getString(R.string.group_chat_title_modify_failure), Toast.LENGTH_SHORT); // toast.setGravity(Gravity.CENTER, 0, 0); // toast.show(); mMsgBox.dismissDialog(); } } }); }
public void handleMessage(android.os.Message msg) { if (msg.what == ErrorCode.OK) { stuPersFromNet.addAll(mDBHelper.fetchLessonPerformance(lessonId, stuId)); // android.util.Log.i("-->>", stuPersFromNet.toString()); lvPerformances.setAdapter(new LessonStatusAdapter(preformstrs)); if (stuPersFromNet.isEmpty()) { findViewById(R.id.btn_parent_confirm).setVisibility(View.VISIBLE); if (!isTeacher) { ContextThemeWrapper themedContext; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { themedContext = new ContextThemeWrapper( LessonStatusActivity.this, android.R.style.Theme_Holo_Light_Dialog_NoActionBar); } else { themedContext = new ContextThemeWrapper( LessonStatusActivity.this, android.R.style.Theme_Light_NoTitleBar); } new AlertDialog.Builder(themedContext) .setTitle("温馨提示") .setMessage("老师还没有评分!") .setCancelable(false) .setPositiveButton( getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }) .create() .show(); } } else { if (stuPersFromNet.get(0).property_id == 10) { findViewById(R.id.btn_parent_confirm).setVisibility(View.VISIBLE); } if (!isTeacher) { findViewById(R.id.btn_parent_confirm).setVisibility(View.GONE); } } } else { mMsgBox.toast(R.string.class_class_status_not_comfired); } };