mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 20:27:58 +03:00
35 lines
1,008 B
Java
35 lines
1,008 B
Java
![]() |
package android.inputmethodservice;
|
||
|
|
||
|
import android.app.Activity;
|
||
|
import android.os.Bundle;
|
||
|
|
||
|
import java.lang.reflect.Constructor;
|
||
|
|
||
|
public class ATLKeyboardViewer extends Activity {
|
||
|
@Override
|
||
|
public void onCreate(Bundle savedState) {
|
||
|
Bundle extras = this.getIntent().getExtras();
|
||
|
|
||
|
if (extras == null || !extras.containsKey("kb_class")) {
|
||
|
System.err.println("ATLKeyboardViewer: usage: `-e 'kb_class=com.example.LatinIME'`");
|
||
|
System.exit(1);
|
||
|
}
|
||
|
|
||
|
String kb_class = extras.getString("kb_class");
|
||
|
|
||
|
InputMethodService ims = null;
|
||
|
|
||
|
try {
|
||
|
Class<? extends InputMethodService> cls = Class.forName(kb_class).asSubclass(InputMethodService.class);
|
||
|
Constructor<? extends InputMethodService> constructor = cls.getConstructor();
|
||
|
ims = constructor.newInstance();
|
||
|
} catch (ReflectiveOperationException e) {
|
||
|
System.err.println("ATLKeyboardViewer: failed to instantiate InputMethodService (kb_class: "+kb_class+")");
|
||
|
e.printStackTrace();
|
||
|
System.exit(1);
|
||
|
}
|
||
|
|
||
|
ims.launch_keyboard();
|
||
|
}
|
||
|
}
|