我寫了一段代碼檢查郵件客戶端裝在設備上沒有,但是沒實現,我的代碼:
public boolean isIntentAvailable() {
final PackageManager packageManager = getApplicationContext().getPackageManager();
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, "[email protected]");
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;
}