- Public class Baseactivity extends Activity {
- Resources Res; //generic resource abbreviation
- @Override
- protected void OnCreate (Bundle savedinstancestate) {
- Requestwindowfeature (Window.feature_no_title); //Do not show title
- super.oncreate (savedinstancestate);
- res = getresources (); //generic resource abbreviation
- //optimize IME mode
- int inputmode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;
- GetWindow (). Setsoftinputmode (Inputmode);
- }
- /**
- * Check whether the string is an empty object or an empty string
- *
- * @param str
- * @return is NULL returns TRUE, NOT NULL returns false
- */
- Public boolean isNull (String str) {
- if (null = = STR | | "". Equals (str) | | "null". Equalsignorecase (str)) {
- return true;
- } Else {
- return false;
- }
- }
- /**
- * Check if string is string
- *
- * @param str
- * @return is NULL returns TRUE, NOT NULL returns false
- */
- Public boolean isstr (String str) {
- return!isnull (str);
- }
- /**
- * Jump from Current activity to target activity,<br>
- * If the target activity has been opened, re-display,<br>
- * If you have never opened, create a new open
- *
- * @param CLS
- */
- public void Gotoexistactivity (class<?> cls) {
- Intent Intent;
- Intent = New Intent (this, CLS);
- Intent.addflags (Intent.flag_activity_reorder_to_front);
- StartActivity (Intent);
- }
- /**
- * Create a new activity open
- *
- * @param CLS
- */
- public void Gotoactivity (class<?> cls) {
- Intent Intent;
- Intent = New Intent (this, CLS);
- StartActivity (Intent);
- }
- /**
- * Generic message hint
- *
- * @param resId
- */
- public void toast (int resId) {
- Toast.maketext (This, ResId, Toast.length_short). Show ();
- }
- /**
- * Generic message hint
- *
- * @param resId
- */
- public void Toast (String msg) {
- Toast.maketext (This, MSG, Toast.length_short). Show ();
- }
- /**
- * Get string from resource
- *
- * @param resId
- * @return
- */
- Public String getstr (int resId) {
- return res.getstring (resId);
- }
- /**
- * Get string from EditText
- *
- * @param editText
- * @return
- */
- Public String getstr (EditText EditText) {
- return Edittext.gettext (). toString ();
- }
- @Override
- Public boolean onKeyDown (int keycode, keyevent event) {
- switch (keycode) {
- Case Keyevent.keycode_back:
- This.finish ();
- }
- return Super.onkeydown (KeyCode, event);
- }
- }
General methods of Android activity base class