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.
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.