问题描述
- 检查邮件客户端装在设备
-
我写了一段代码检查邮件客户端装在设备上没有,但是没实现,我的代码:public boolean isIntentAvailable() { final PackageManager packageManager = getApplicationContext().getPackageManager(); final Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_EMAIL, "vin@gmail.com"); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.GET_META_DATA); return list.size() > 0;
}
解决方案
我用下面的代码实现过。试试
public static boolean isMailClientPresent(Context context){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
final PackageManager packageManager = context.getPackageManager();
List<ResolveInfo> list = packageManager.queryIntentActivities(intent, 0);
if(list.size() == 0)
return false;
else
return true;
}
时间: 2024-10-28 14:09:18