2 o 1001 o O_1001_O 于 2012.10.09 15:25 提问

检查邮件客户端装在设备

我写了一段代码检查邮件客户端装在设备上没有,但是没实现,我的代码:

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;

}

1个回答

ce_la_vie
ce_la_vie   2012.10.09 16:06
已采纳

我用下面的代码实现过。试试

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;

}

Csdn user default icon
上传中...
上传图片
插入图片