this is my problem. Everytime i hit the backbutton on any android device, the application automatically closes. Is there any way i could make the back button of the device load the previous activity?
Here are the codes
package com.phonegap.mobilemone;
import com.phonegap.DroidGap;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebView;
public class KeyBoard {
private WebView mAppView;
private DroidGap mGap;
public KeyBoard(DroidGap gap, WebView view)
{
mAppView = view;
mGap = gap;
}
public void showKeyBoard() {
InputMethodManager mgr = (InputMethodManager) mGap.getSystemService(Context.INPUT_METHOD_SERVICE);
// only will trigger it if no physical keyboard is open
mgr.showSoftInput(mAppView, InputMethodManager.SHOW_IMPLICIT);
((InputMethodManager) mGap.getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(mAppView, 0);
}
public void hideKeyBoard() {
InputMethodManager mgr = (InputMethodManager) mGap.getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(mAppView.getWindowToken(), 0);
}
}
In android, when you press
back buttonyou goes to previousActivity, But when developingPhoneGapapp, you are working on singleActivity(this is the reason when you pressbackbutton, application gets close). You need to implement your own listener which will listenbackkey press.How to create Android Back Button handler:
phonegap 0.9.5 and later:
// This is your app’s init method. Here’s an example of how to use it
phonegap 0.9.4 and earlier:
// This is your app’s init method. Here’s an example of how to use it
Here are References :
Back button handler
CATCHING ANDROID’S BACK BUTTON IN PHONEGAP