使用Google翻译叠加层中的复制选项隐藏PopupMenu?

时间:2016-09-29 20:45:15

标签: android android-intent google-translate

我尝试使用应用内翻译并启动Google翻译叠加层,如此Android博文中所述:In-app translations in Android Marshmallow

作为一个基本示例(假设安装了Translate应用程序),这涉及触发这样的意图:

String text = "Dorothy lived...";
Intent intent = new Intent();
intent.setAction(Intent.ACTION_PROCESS_TEXT);
intent.setType("text/plain");
intent.setPackage("com.google.android.apps.translate");
intent.putExtra(Intent.EXTRA_PROCESS_TEXT, text);
startActivity(intent);

这很好用;但是,与博客文章中显示的屏幕截图不同,实际的Google Translate叠加层有一个PopupMenu,其中包含翻译结果的“复制”选项。有没有办法压制这个PopupMenu?您可以轻松地将原始语言和目标语言设置为相同的语言,并使用此功能复制整个原始文本。我想提供翻译单词或段落的功能,同时保护原始内容不受复制/粘贴。

我想我可以使用Google Translate API执行此操作,但触发带有意图的Google Translate应用程序非常简单。也许有一个Extra值可能会导致更基本的叠加?

enter image description here

0 个答案:

没有答案