gpt4 book ai didi

android - Intent.Action_Send 和 ShareCompat.IntentBuilder 对话框缺少应用程序图标

转载 作者:太空狗 更新时间:2023-10-29 14:15:49 26 4
gpt4 key购买 nike

我有以下代码启动发送电子邮件消息的 Intent

@Override
public void onPostExecute(File outfile) {
ProgressDialogRequestIcons d1 = (ProgressDialogRequestIcons) fm.findFragmentByTag("DIALOG_F2");
d1.dialogDismiss();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
Uri uri = Uri.fromFile(outfile);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.app_email) });
intent.putExtra(Intent.EXTRA_SUBJECT, "Icon Support for" + " " + this.getResources().getString(R.string.app_name));
intent.putExtra(Intent.EXTRA_TEXT, "I am using " + Build.DEVICE + " with Android version " + Build.VERSION.RELEASE);
this.startActivity(Intent.createChooser(intent, "Send eMail.."));
}

然而,当弹出对话框选择要发送的应用程序时,它显示没有像这样的图标

enter image description here

然后我尝试了如下的另一种方法,但仍然有同样的问题。

public void startEmailIntentWithPackage(File icon_request){
try{
ShareCompat.IntentBuilder.from(this)
.setType("application/zip")
.addStream(Uri.parse("file://" + icon_request.getAbsolutePath()))
.addEmailTo(getString(R.string.app_email))
.setSubject("Icon Support for" + " " + this.getResources().getString(R.string.app_name))
.setText("I am using " + Build.DEVICE + " with Android version " + Build.VERSION.RELEASE)
.setChooserTitle("Send Email..")
.startChooser();
}
catch (Exception ignored)
{
}
}

最佳答案

AsyncTask 的一个烦恼是默认情况下返回序列化执行,这在 API 级别 13 中正式开始。当库在内部使用 AsyncTask 时,情况会变得更糟...并且自己不使用 executeOnExecutor() 选择加入线程池。

我的猜测是:

  • 您使用execute() 启动了一个任务
  • ShareCompat 使用 execute() 启动另一个任务...然后阻塞直到第一个任务完成

解决方案是:

  • 自己使用executeOnExecutor(),或者
  • 使用普通的 Thread,特别是当您不需要 onPostExecute()onProgressUpdate() fragment 时 AsyncTask

关于android - Intent.Action_Send 和 ShareCompat.IntentBuilder 对话框缺少应用程序图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22333447/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com