Esempio n. 1
0
  @Override
  public void finish() {
    if (!isCanceled()) {
      final String message = ((EditText) findViewById(android.R.id.text1)).getText().toString();

      if (message.length() > 0) {
        final Intent resultIntent = new Intent();

        /*
         * This extra is the data to ourselves: either for the Activity or the BroadcastReceiver. Note
         * that anything placed in this Bundle must be available to Locale's class loader. So storing
         * String, int, and other standard objects will work just fine. Parcelable objects are not
         * acceptable, unless they also implement Serializable. Serializable objects must be standard
         * Android platform objects (A Serializable class private to this plug-in's APK cannot be
         * stored in the Bundle, as Locale's classloader will not recognize it).
         */
        final Bundle resultBundle =
            PluginBundleManager.generateBundle(getApplicationContext(), message);
        resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE, resultBundle);

        /*
         * The blurb is concise status text to be displayed in the host's UI.
         */
        final String blurb = generateBlurb(getApplicationContext(), message);
        resultIntent.putExtra(com.twofortyfouram.locale.Intent.EXTRA_STRING_BLURB, blurb);

        setResult(RESULT_OK, resultIntent);
      }
    }

    super.finish();
  }
Esempio n. 2
0
  @Override
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    BundleScrubber.scrub(getIntent());

    final Bundle localeBundle =
        getIntent().getBundleExtra(com.twofortyfouram.locale.Intent.EXTRA_BUNDLE);
    BundleScrubber.scrub(localeBundle);

    setContentView(R.layout.main);

    if (null == savedInstanceState) {
      if (PluginBundleManager.isBundleValid(localeBundle)) {
        final String message =
            localeBundle.getString(PluginBundleManager.BUNDLE_EXTRA_STRING_MESSAGE);
        ((EditText) findViewById(android.R.id.text1)).setText(message);
      }
    }
  }