Intent not found Gmail App for email... 请查看代码 - 我已经查看了其他答案... Xiaomi MI 8 API 27

Posted

技术标签:

【中文标题】Intent not found Gmail App for email... 请查看代码 - 我已经查看了其他答案... Xiaomi MI 8 API 27【英文标题】:Intent not finding Gmail App for email... Please see code - I've look at other answers... Xiaomi MI 8 API 27 【发布时间】:2020-01-05 07:45:13 【问题描述】:

设置意图非常简单......

我已经尝试在这两个区域使用 ACTION_SEND 来代替 ACTION_SENDTO。

 Uri uri = FileProvider.getUriForFile(
            context
            , context.getString(R.string.package_file_provider)
            , zipFile);


    Intent intent = new Intent(Intent.ACTION_SEND, Uri.fromParts("mailto:", "noreply@gmail.com", null));
    intent.putExtra(Intent.EXTRA_SUBJECT, zipFileName);
    intent.putExtra(Intent.EXTRA_TEXT, "Your file is attached.");
    intent.putExtra(Intent.EXTRA_STREAM, uri);
    //      intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    if(isMailClientPresent(context)) 
        startActivity(Intent.createChooser(intent, "Send file via email..."));
    

在调用电子邮件意图之前专门检查电子邮件应用程序

public static boolean isMailClientPresent(Context context)
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    final PackageManager packageManager = context.getPackageManager();
    List<ResolveInfo> list = packageManager.queryIntentActivities(intent, 0);

    if(list.size() == 0)
        return false;
    else
        return true;

我已经查看了许多其他答案,但似乎没有一个可以解决这个问题...我找到了上面的函数并且它返回 true...这意味着它找到了应用程序...为什么哈迪斯会这样做我仍然收到没有应用程序可以执行此操作吗?

【问题讨论】:

您的意图和isMailClientPresent 方法正在检查不同的条件。 @VladyslavMatviienko 感谢您指出这一点...我刚刚更改了它,同样的事情发生了。 【参考方案1】:

试试这个

private void addAutoStartup() 

try 
    Intent intent = new Intent();
    String manufacturer = android.os.Build.MANUFACTURER;
    if ("xiaomi".equalsIgnoreCase(manufacturer)) 
        intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
     else if ("oppo".equalsIgnoreCase(manufacturer)) 
        intent.setComponent(new ComponentName("com.coloros.safecenter", "com.coloros.safecenter.permission.startup.StartupAppListActivity"));
     else if ("vivo".equalsIgnoreCase(manufacturer)) 
        intent.setComponent(new ComponentName("com.vivo.permissionmanager", "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"));
     else if ("Letv".equalsIgnoreCase(manufacturer)) 
        intent.setComponent(new ComponentName("com.letv.android.letvsafe", "com.letv.android.letvsafe.AutobootManageActivity"));
     else if ("Honor".equalsIgnoreCase(manufacturer)) 
        intent.setComponent(new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager.optimize.process.ProtectActivity"));
    

    List<ResolveInfo> list = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if  (list.size() > 0) 
        startActivity(intent);
    
 catch (Exception e) 
    Log.e("exc" , String.valueOf(e));

【讨论】:

Raju Tukadiya 结果告诉我检查应用设置 很奇怪...我似乎在它提供的应用程序列表中找不到 gmail...我想我会尝试下载其他一些电子邮件应用程序,看看是否是问题所在。我迷路了 让我检查一下给我一些其他联系方式到我的电子邮件:rajutukadiya3@gmail.com

以上是关于Intent not found Gmail App for email... 请查看代码 - 我已经查看了其他答案... Xiaomi MI 8 API 27的主要内容,如果未能解决你的问题,请参考以下文章

These relative modules were not found:...{"sourceM ap":false} 报错解决

default activity not found android studio

chkconfig: command not found

Android开发:default activity not found

Error in Android Studio - "Default Activity Not Found"

Centos安装 Apache2.4提示 APR not found的解决办法