Android自定義軟鍵盤輸入法,隱藏系統輸入法顯示游標的實現
阿新 • • 發佈:2019-01-22
android實現自定義軟鍵盤,先上圖看效果,效果基本上是仿ios輸入法實現的
這裡是實現隱藏系統輸入法,同時讓EditText能獲取游標的程式碼部分(通過反射呼叫):
<span style="font-size:18px;">keyBoardLabel = (EditText) rootView .findViewById(R.id.wifi_key_input_edittext); // this.getActivity() // .getWindow() // .setSoftInputMode( // WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); try { Class<EditText> cls = EditText.class; Method setShowSoftInputOnFocus; setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class); setShowSoftInputOnFocus.setAccessible(true); setShowSoftInputOnFocus.invoke(keyBoardLabel, false); } catch (Exception e) { e.printStackTrace(); }</span>
先看XML檔案: 這裡使用到了ViewStub,為了不用一次性載入 過多的佈局檔案資源.ViewStub能更省記憶體!!
<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="320dp" android:layout_height="320dp" android:background="@drawable/wifi_key_bg" android:clickable="true" android:gravity="center_horizontal" android:orientation="vertical" > <ImageView android:id="@+id/wifi_keyboard_exit" style="@style/Exit" android:src="@drawable/wifi_key_return" /> <!-- keyboard view --> <LinearLayout android:layout_width="320dp" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical" android:paddingLeft="29dp" android:paddingRight="29dp" > <!-- keyboard top --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:gravity="center" android:paddingBottom="3dp" > <ImageButton android:id="@+id/wifi_key_lpage_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_lpage" /> <EditText android:id="@+id/wifi_key_input_edittext" android:layout_width="150dp" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" android:background="@drawable/wifi_key_edit_bg" android:gravity="center" android:singleLine="true" android:text="" android:textCursorDrawable="@drawable/edittext_cursor" /> <ImageButton android:id="@+id/wifi_key_rpage_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_rpage" /> </LinearLayout> <!-- true key board include other layout --> <ViewStub android:id="@+id/key_board_input_lower_viewstub" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout="@layout/key_board_lower_layout" android:paddingBottom="3dp" android:visibility="gone" /> <ViewStub android:id="@+id/key_board_input_upper_viewstub" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout="@layout/key_board_upper_layout" android:paddingBottom="3dp" android:visibility="gone" /> <ViewStub android:id="@+id/key_board_input_number_viewstub" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inflatedId="@+id/inflatedStart" android:layout="@layout/key_board_number" android:paddingBottom="3dp" android:visibility="gone" /> <ViewStub android:id="@+id/key_board_input_symbol1_viewstub" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inflatedId="@+id/inflatedStart" android:layout="@layout/key_board_symbol_1" android:paddingBottom="3dp" android:visibility="gone" /> <ViewStub android:id="@+id/key_board_input_symbol2_viewstub" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inflatedId="@+id/inflatedStart" android:layout="@layout/key_board_symbol_2" android:paddingBottom="3dp" android:visibility="gone" /> </LinearLayout> <!-- bottom change and delete --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="-3dp" > <ImageButton android:id="@+id/wifi_key_board_delete_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_delete" /> <ImageButton android:id="@+id/wifi_key_board_connect_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="1dp" android:background="@drawable/wifi_key_connect" /> </LinearLayout> </LinearLayout></span>
接著是單個鍵盤的的XML佈局,展示一個比較多鍵盤的就好了.其他的都很容易實現了
最後是主要的程式碼部分,上關鍵程式碼,程式碼沒什麼註釋,不過從命名一眼能看出來是什麼,理解思路最重要,實現起來其實很簡單,有什麼疑問留言吧<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" > <!-- top --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageButton android:id="@+id/key_symbol_1_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_1" /> <ImageButton android:id="@+id/key_symbol_2_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_2" /> <ImageButton android:id="@+id/key_symbol_3_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_3" /> <ImageButton android:id="@+id/key_symbol_4_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_4" /> <ImageButton android:id="@+id/key_symbol_5_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_5" /> <ImageButton android:id="@+id/key_symbol_6_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_6" /> <ImageButton android:id="@+id/key_symbol_7_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_7" /> <ImageButton android:id="@+id/key_symbol_8_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_8" /> <ImageButton android:id="@+id/key_symbol_9_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_9" /> <ImageButton android:id="@+id/key_symbol_10_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_10" /> </LinearLayout> <!-- middle --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:orientation="horizontal" > <ImageButton android:id="@+id/key_symbol_11_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_11" /> <ImageButton android:id="@+id/key_symbol_12_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_12" /> <ImageButton android:id="@+id/key_symbol_13_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_13" /> <ImageButton android:id="@+id/key_symbol_14_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_14" /> <ImageButton android:id="@+id/key_symbol_15_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_15" /> <ImageButton android:id="@+id/key_symbol_16_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_16" /> <ImageButton android:id="@+id/key_symbol_17_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_17" /> <ImageButton android:id="@+id/key_symbol_18_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_18" /> <ImageButton android:id="@+id/key_symbol_19_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_19" /> </LinearLayout> <!-- bottom --> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:orientation="horizontal" > <ImageButton android:id="@+id/key_symbol_20_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_20" /> <ImageButton android:id="@+id/key_symbol_21_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_21" /> <ImageButton android:id="@+id/key_symbol_22_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_22" /> <ImageButton android:id="@+id/key_symbol_23_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_23" /> <ImageButton android:id="@+id/key_symbol_24_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_24" /> <ImageButton android:id="@+id/key_symbol_25_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_25" /> <ImageButton android:id="@+id/key_symbol_26_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_26" /> <ImageButton android:id="@+id/key_symbol_27_btn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/wifi_key_symbol_27" /> </LinearLayout> </LinearLayout>
package com.moco.launcher.wifi;
import java.lang.reflect.Method;
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.text.InputType;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.Switch;
import android.widget.TextView;
import com.moco.launcher.R;
import com.moco.launcher.activity.NewWifiSettingsActivity;
import com.oazon.common.Logger;
import com.oazon.moco.serialport.SerialControll;
import com.oazon.voicelib.service.SpeechManage;
public class WifInputFragment extends Fragment implements OnClickListener {
private String TAG = "WifInputFragment";
private View rootView;
private ConnectImpl connectImpl;
private ImageView exitImg;
private ViewStub lowerStub, upperStub, numberStub, symbol1Stub,
symbol2Stub;
private EditText keyBoardLabel;
private ImageButton wifi_key_lpage_btn, wifi_key_board_delete_btn,
wifi_key_rpage_btn, wifi_key_board_connect_btn;
private StringBuffer mBuffer;
public enum INPUT_TYPE {
UPPER, LOWER, NUMBER, SYMBOL1, SYMBOL2
}
private INPUT_TYPE currentType;
private NewWifiSettingsActivity mContext;
private PopupWindow mPopupWindow;
private TextView tv;
public WifInputFragment(ConnectImpl impl) {
connectImpl = impl;
mBuffer = new StringBuffer();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.i(TAG, "enter onCreateView---------");
rootView = inflater.inflate(R.layout.wifi_keyboard_layout, container,
false);
init();
loadKeyboardStub(INPUT_TYPE.LOWER);
initKeyBoardLayout();
initPopupWindow();
return rootView;
}
private void initImageBG() {
if (currentType == INPUT_TYPE.LOWER) {
wifi_key_lpage_btn
.setBackgroundResource(R.drawable.wifi_key_point_change);
wifi_key_rpage_btn
.setBackgroundResource(R.drawable.wifi_key_number_change);
} else if (currentType == INPUT_TYPE.NUMBER) {
wifi_key_lpage_btn
.setBackgroundResource(R.drawable.wifi_key_abc_change);
wifi_key_rpage_btn
.setBackgroundResource(R.drawable.wifi_key_symbol_change);
} else if (currentType == INPUT_TYPE.SYMBOL1) {
wifi_key_lpage_btn
.setBackgroundResource(R.drawable.wifi_key_number_change);
wifi_key_rpage_btn
.setBackgroundResource(R.drawable.wifi_key_point_change);
} else if (currentType == INPUT_TYPE.SYMBOL2) {
wifi_key_lpage_btn
.setBackgroundResource(R.drawable.wifi_key_symbol_change);
wifi_key_rpage_btn
.setBackgroundResource(R.drawable.wifi_key_abc_change);
}
}
private void initPopupWindow() {
tv = new TextView(mContext);
tv.setTextSize(30);
tv.setTextColor(Color.BLACK);
tv.setGravity(Gravity.CENTER_HORIZONTAL);
tv.setPadding(0, 0, 0, 50);
mPopupWindow = new PopupWindow(tv, -2, -2);
mPopupWindow
.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
private void init() {
mContext = (NewWifiSettingsActivity) getActivity();
exitImg = (ImageView) rootView.findViewById(R.id.wifi_keyboard_exit);
exitImg.setOnClickListener(this);
keyBoardLabel = (EditText) rootView
.findViewById(R.id.wifi_key_input_edittext);
// this.getActivity()
// .getWindow()
// .setSoftInputMode(
// WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
try {
Class<EditText> cls = EditText.class;
Method setShowSoftInputOnFocus;
setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus",
boolean.class);
setShowSoftInputOnFocus.setAccessible(true);
setShowSoftInputOnFocus.invoke(keyBoardLabel, false);
} catch (Exception e) {
e.printStackTrace();
}
// keyBoardLabel.setCursorVisible(true);
// keyBoardLabel.requestFocus();
wifi_key_lpage_btn = (ImageButton) rootView
.findViewById(R.id.wifi_key_lpage_btn);
wifi_key_lpage_btn.setOnClickListener(this);
wifi_key_rpage_btn = (ImageButton) rootView
.findViewById(R.id.wifi_key_rpage_btn);
wifi_key_rpage_btn.setOnClickListener(this);
wifi_key_board_connect_btn = (ImageButton) rootView
.findViewById(R.id.wifi_key_board_connect_btn);
wifi_key_board_connect_btn.setOnClickListener(this);
wifi_key_board_delete_btn = (ImageButton) rootView
.findViewById(R.id.wifi_key_board_delete_btn);
wifi_key_board_delete_btn.setOnClickListener(this);
wifi_key_board_delete_btn
.setOnTouchListener(new KeyDeleteOnTouchListener());
upperStub = (ViewStub) rootView
.findViewById(R.id.key_board_input_upper_viewstub);
upperStub.inflate();
lowerStub = (ViewStub) rootView
.findViewById(R.id.key_board_input_lower_viewstub);
lowerStub.inflate();
numberStub = (ViewStub) rootView
.findViewById(R.id.key_board_input_number_viewstub);
numberStub.inflate();
symbol1Stub = (ViewStub) rootView
.findViewById(R.id.key_board_input_symbol1_viewstub);
symbol1Stub.inflate();
symbol2Stub = (ViewStub) rootView
.findViewById(R.id.key_board_input_symbol2_viewstub);
symbol2Stub.inflate();
}
private void initKeyBoardLayout() {
for (int i = 0; i < KeyBoardResource.UpperKeyBtnIds.length; i++) {
ImageButton imgBtn = (ImageButton) rootView
.findViewById(KeyBoardResource.UpperKeyBtnIds[i]);
if (imgBtn != null)
imgBtn.setOnTouchListener(new KeyImageBtnTouchListener());
}
for (int i = 0; i < KeyBoardResource.LowerKeyBtnIds.length; i++) {
ImageButton imgBtn = (ImageButton) rootView
.findViewById(KeyBoardResource.LowerKeyBtnIds[i]);
if (imgBtn != null)
imgBtn.setOnTouchListener(new KeyImageBtnTouchListener());
}
for (int i = 0; i < KeyBoardResource.NumberKeyBtnIds.length; i++) {
ImageButton imgBtn = (ImageButton) rootView
.findViewById(KeyBoardResource.NumberKeyBtnIds[i]);
if (imgBtn != null)
imgBtn.setOnTouchListener(new KeyImageBtnTouchListener());
}
for (int i = 0; i < KeyBoardResource.symbol1.length; i++) {
ImageButton imgBtn = (ImageButton) rootView
.findViewById(KeyBoardResource.symbol1[i]);
if (imgBtn != null)
imgBtn.setOnTouchListener(new KeyImageBtnTouchListener());
}
for (int i = 0; i < KeyBoardResource.symbol2.length; i++) {
ImageButton imgBtn = (ImageButton) rootView
.findViewById(KeyBoardResource.symbol2[i]);
if (imgBtn != null)
imgBtn.setOnTouchListener(new KeyImageBtnTouchListener());
}
}
private class KeyDeleteOnTouchListener implements OnTouchListener {
private long currentTimeMillis_start;
private long currentTimeMillis_move = 0;
int duration = 0;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
currentTimeMillis_start = System.currentTimeMillis();
break;
case MotionEvent.ACTION_MOVE:
currentTimeMillis_move = System.currentTimeMillis();
duration = (int) (currentTimeMillis_move - currentTimeMillis_start);
if (duration > 100) {
if (mBuffer != null && mBuffer.length() > 0) {
mBuffer.deleteCharAt(mBuffer.length() - 1);
keyBoardLabel.setText(mBuffer.toString());
} else {
keyBoardLabel.setText("");
}
currentTimeMillis_start += 100;
keyBoardLabel.setSelection(mBuffer.length());
}
break;
case MotionEvent.ACTION_UP:
break;
default:
break;
}
return false;
}
}
private class KeyImageBtnTouchListener implements OnTouchListener {
private String result = "";
private int id;
private float moveX;
private float moveY;
private float startY;
private float startX;
private float durationX;
private float durationY;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
id = v.getId();
if (id == R.id.key_lower_change_btn) {
changeUpperAndLowerBoard();
return true;
} else if (id == R.id.key_upper_change_btn) {
changeUpperAndLowerBoard();
return true;
}
startX = event.getRawX();
startY = event.getRawY();
result = KeyBoardResource.getCharById(v.getId());
Log.i(TAG, "click char is:" + result);
if (id == R.id.key_symbol_44_btn) {
tv.setText("");
tv.setBackgroundResource(R.drawable.wifi_key_board_1);
} else if (id == R.id.key_symbol_51_btn) {
tv.setText("");
tv.setBackgroundResource(R.drawable.wifi_key_board_2);
} else {
tv.setText(result);
tv.setBackgroundResource(R.drawable.wifi_key_board_up_bg);
}
if (currentType == INPUT_TYPE.NUMBER) {
mPopupWindow.showAsDropDown(v, 10, -90);
} else {
mPopupWindow.showAsDropDown(v, -10, -90);
}
break;
case MotionEvent.ACTION_MOVE:
moveX = event.getRawX();
moveY = event.getRawY();
durationX = Math.abs(moveX - startX);
durationY = Math.abs(moveY - startY);
if (durationX > 10 || durationY > 10) {
mPopupWindow.dismiss();
}
break;
case MotionEvent.ACTION_UP:
mPopupWindow.dismiss();
mBuffer.append(result);
Log.i(TAG, "after mBuffer char is:" + mBuffer.toString());
keyBoardLabel.setText(mBuffer);
keyBoardLabel.setSelection(mBuffer.length());
break;
default:
break;
}
return true;
}
}
@SuppressLint("NewApi")
private void loadKeyboardStub(INPUT_TYPE type) {
upperStub.setVisibility(View.GONE);
lowerStub.setVisibility(View.GONE);
numberStub.setVisibility(View.GONE);
symbol1Stub.setVisibility(View.GONE);
symbol2Stub.setVisibility(View.GONE);
switch (type) {
case UPPER:
upperStub.setVisibility(View.VISIBLE);
break;
case LOWER:
lowerStub.setVisibility(View.VISIBLE);
break;
case NUMBER:
numberStub.setVisibility(View.VISIBLE);
break;
case SYMBOL1:
symbol1Stub.setVisibility(View.VISIBLE);
break;
case SYMBOL2:
symbol2Stub.setVisibility(View.VISIBLE);
break;
}
currentType = type;
initImageBG();
}
private void deleteBuffer() {
Log.i(TAG, "enter deleteBuffer()");
if (mBuffer != null && mBuffer.length() > 0) {
mBuffer.deleteCharAt(mBuffer.length() - 1);
}
if (mBuffer != null && mBuffer.length() > 0) {
keyBoardLabel.setText(mBuffer.toString());
} else {
keyBoardLabel.setText("");
}
keyBoardLabel.setSelection(mBuffer.length());
}
public void change2RightKeyBoard() {
if (currentType == INPUT_TYPE.LOWER || currentType == INPUT_TYPE.UPPER)
currentType = INPUT_TYPE.NUMBER;
else if (currentType == INPUT_TYPE.NUMBER)
currentType = INPUT_TYPE.SYMBOL1;
else if (currentType == INPUT_TYPE.SYMBOL1)
currentType = INPUT_TYPE.SYMBOL2;
else if (currentType == INPUT_TYPE.SYMBOL2)
currentType = INPUT_TYPE.LOWER;
loadKeyboardStub(currentType);
}
public void change2LeftKeyBoard() {
if (currentType == INPUT_TYPE.LOWER || currentType == INPUT_TYPE.UPPER)
currentType = INPUT_TYPE.SYMBOL2;
else if (currentType == INPUT_TYPE.SYMBOL2)
currentType = INPUT_TYPE.SYMBOL1;
else if (currentType == INPUT_TYPE.SYMBOL1)
currentType = INPUT_TYPE.NUMBER;
else if (currentType == INPUT_TYPE.NUMBER)
currentType = INPUT_TYPE.LOWER;
loadKeyboardStub(currentType);
}
public void changeUpperAndLowerBoard() {
if (currentType == INPUT_TYPE.UPPER)
loadKeyboardStub(INPUT_TYPE.LOWER);
else if (currentType == INPUT_TYPE.LOWER)
loadKeyboardStub(INPUT_TYPE.UPPER);
loadKeyboardStub(currentType);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.wifi_key_lpage_btn:
change2LeftKeyBoard();
break;
case R.id.wifi_key_rpage_btn:
change2RightKeyBoard();
break;
case R.id.wifi_keyboard_exit:
clearEditText();
getActivity().onBackPressed();
break;
case R.id.wifi_key_board_delete_btn:
deleteBuffer();
break;
case R.id.wifi_key_board_connect_btn:
Log.i(TAG, "");
if (mBuffer.toString().equals("com.moco")) {
ComponentName componetName = new ComponentName(
"com.example.dragontest",
"com.example.dragontest.MainActivity");
Intent intent = new Intent();
intent.setComponent(componetName);
startActivity(intent);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
((NewWifiSettingsActivity) getActivity()).connect(mBuffer
.toString());
clearEditText();
connectImpl.exit(ConnectImpl.INPUT);
break;
default:
break;
}
}
public void clearEditText() {
mBuffer.delete(0, mBuffer.length());
if (keyBoardLabel != null)
keyBoardLabel.setText("");
}
@Override
public void onPause() {
Logger.d(TAG, "onPause==");
SerialControll.getInstance().startControl();
SpeechManage.getInstance().startWake();
super.onPause();
}
@Override
public void onResume() {
Logger.d(TAG, "onResume==");
super.onResume();
SerialControll.getInstance().stopControl();
SpeechManage.getInstance().stopWake();
}
@Override
public void onDestroyView() {
super.onDestroyView();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onLowMemory() {
Logger.d(TAG, "onLowMemory==");
SerialControll.getInstance().startControl();
SpeechManage.getInstance().startWake();
super.onLowMemory();
}
}