Question

I am writing an InputMethodService, basically just a soft keyboard, from which I start another activity:

class Foo extends InputMethodService {
    // ...
    private void startNewActivity() {
        Intent i = new Intent(this, NewActivity.class);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(i);
    }
    // ...
}

But when I do this, the user will be in the process of typing. For example, the user presses the 'a' key to start the new activity. Is there a way, when the user finishes the new activity, that I can return them to typing and put the keyboard back as it were?

Was it helpful?

Solution

It is up the the application in which you are typing to store the data you've typed during it's onPause() and related methods. Then the app should restore its state in onResume(). Notice neither of these can be controlled by your keyboard.

One thing you might be able to do (depending on the nature of the activity you are starting) is let the activity be a dialog. Then it will appear over the current activity, and when the dialog is closed (back button pressed or you call finish()) everything returns to how it was.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top