1

I tried running a share example apk on Chrome ARC Welder having following code.

    Intent share = new Intent(android.content.Intent.ACTION_SEND);
    share.setType("text/plain");
    share.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    share.putExtra(Intent.EXTRA_SUBJECT, "Title Of The Post");
    share.putExtra(Intent.EXTRA_TEXT, "Content of post");

    startActivity(Intent.createChooser(share, "Share"));

When i run this then window asking to save a file appears. When save and open the file then only the content appears.

Is there some different way of handling share / action_send in Chome ARC ?

I tried searching for reference materials / guides but don't seem to find it. Any reference materials / guides or any examples will be very helpful. Thanks.

Xan
  • 74,770
  • 16
  • 179
  • 206
Gunxsword Fan
  • 95
  • 1
  • 7

1 Answers1

1

Unfortunately, the apps to handle those intents are not available in the chromebooks. So, you have seen that problem. If you wish to share it via email, try the following approach:

    if (isChromeApp()) {

            Intent emailIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("mailto:"));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
            emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body));
            startActivity(emailIntent);

        } else {
//Android intent handler code
}

To know if it is chromeapp, you can use following function:

private static final String CHROMIUM="chromium";


public static boolean isChromeApp() {
        if (Build.MANUFACTURER != null) {
            Log.d("manufacturer", Build.MANUFACTURER);
        }
        boolean isChromeApp = Build.MANUFACTURER != null
                && Build.MANUFACTURER.equalsIgnoreCase(CHROMIUM);
        Log.d("isChromeApp", isChromeApp ? "true" : "false");
        return isChromeApp;
    }

It will open up your default email client installed in your computer. Hope this helps.

Dipendra
  • 1,547
  • 19
  • 33
  • 1
    I think you also need to mention that CHROMIUM is a constant final static String = "chromium"-- but anyway, this may not be super clean but I just used something like `return (android.os.Build.BRAND.equals("chromium") && android.os.Build.MANUFACTURER.equals("chromium"));` and it seems to work. Didn't even check for null, but that's how I roll. – fattire Apr 21 '15 at 04:07