Esempio n. 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    String lName = WritePadManager.getLanguageName();
    WritePadManager.setLanguage(lName, this);

    // initialize ink inkView class
    inkView = (InkView) findViewById(R.id.ink_view);

    recognizedTextContainer = (LinearLayout) findViewById(R.id.recognized_text_container);
    readyText = (TextView) findViewById(R.id.ready_text);

    Display defaultDisplay = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    defaultDisplay.getSize(size);
    int screenHeight = size.y;
    int textViewHeight = 15 * screenHeight / 100;
    final LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, textViewHeight);
    recognizedTextContainer.setLayoutParams(params);
    readyText.setLayoutParams(params);

    inkView.setRecognizedTextContainer(recognizedTextContainer);
    inkView.setReadyText(readyText);

    mConnection =
        new ServiceConnection() {
          public void onServiceConnected(ComponentName className, IBinder service) {
            // This is called when the connection with the service has been
            // established, giving us the service object we can use to
            // interact with the service.  Because we have bound to a explicit
            // service that we know is running in our own process, we can
            // cast its IBinder to a concrete class and directly access it.
            mBoundService = ((RecognizerService.RecognizerBinder) service).getService();
            mBoundService.mHandler = inkView.getHandler();
          }

          public void onServiceDisconnected(ComponentName className) {
            // This is called when the connection with the service has been
            // unexpectedly disconnected -- that is, its process crashed.
            // Because it is running in our same process, we should never
            // see this happen.
            mBoundService = null;
          }
        };

    bindService(
        new Intent(RecoTest.this, RecognizerService.class), mConnection, Context.BIND_AUTO_CREATE);
  }
Esempio n. 2
0
 @Override
 protected void onDestroy() {
   unbindService(mConnection);
   super.onDestroy();
   if (mRecoInit) {
     WritePadManager.recoFree();
   }
   mRecoInit = false;
 }