3

我正在制作基于日历的应用程序,我正在尝试将我的应用程序转到默认日历并在互联网上搜索,但我不能这样做,所以可以使用 Intent Advance 打开默认日历,谢谢。

4

2 回答 2

3

试试这个

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);
}
于 2013-01-23T04:42:33.973 回答
1
Intent intent = new Intent(Intent.ACTION_EDIT);  
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("title", "Some title");
intent.putExtra("description", "Some description");
intent.putExtra("beginTime", eventStartInMillis);
intent.putExtra("endTime", eventEndInMillis);
startActivity(intent);

该文档可在此处找到

于 2013-01-23T04:40:52.207 回答