问题描述
- 获取安卓的默认日历问题
-
做了一个日历应用,想要让我的应用到默认日历中,然后在网上搜索,但是无法实现,能不能用intent开放一个默认日历?请大家帮忙,谢谢。
解决方案
应该是这么实现就可以:
PackageManager packmngr = this.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> list = packmngr.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);
ResolveInfo Resolvebest = null;
for (final ResolveInfo info : list){
if (info.activityInfo.packageName.endsWith(".calendar"))
Resolvebest = info;
}
if (Resolvebest != null){
intent.setClassName(Resolvebest.activityInfo.packageName,
Resolvebest.activityInfo.name);
startActivity(intent);
}
时间: 2024-09-30 16:55:49