在运行 2.3 的设备上测试时出现 ActivityNotFoundException [英] ActivityNotFoundException when testing on a device running 2.3

查看:18
本文介绍了在运行 2.3 的设备上测试时出现 ActivityNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功将事件添加到本机日历,并且适用于 Android API 级别 14 或更高版本.

I have successfully added event to Native calendar, and works fine for Android API Level 14 or higher.

我尝试了@VishalKhakhkhar 的代码,但我仍然无法解决这个问题?我收到错误消息:在运行 2.3.6 的设备上进行测试时,找不到处理 Intent { act=android.intent.action.EDIT typ=vnd.android.cursor.item/event 的活动

I tried @VishalKhakhkhar's code, but i am still not able to resolve this issue? I'm getting error : No Activity found to handle Intent { act=android.intent.action.EDIT typ=vnd.android.cursor.item/event when testing on a device running 2.3.6

请参阅下面的更新代码,尝试解决此问题:-

see my updated code below, try to resolve this issue:-

    Button btnEvents = (Button) findViewById(R.id.button1);
    btnEvents.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            long startMillis = 0; 
            long endMillis = 0; 
            Calendar beginTime = Calendar.getInstance(); 
            beginTime.set(2014, 1, 16, 16, 0);  
            startMillis = beginTime.getTimeInMillis(); 
            Calendar endTime = Calendar.getInstance(); 
            endTime.set(2014, 1, 16, 22, 30);
            endMillis= endTime.getTimeInMillis();

            if (Build.VERSION.SDK_INT >= 14) {
                Intent intent = new Intent(Intent.ACTION_EDIT).setData(Events.CONTENT_URI)
                    .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startMillis)
                    .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endMillis)
                    .putExtra(Events.TITLE, "Title")
                    .putExtra(Events.DESCRIPTION, "Description")
                    .putExtra(Events.EVENT_LOCATION, "Location")
                    .putExtra(Reminders.HAS_ALARM, true)
                    .putExtra(Reminders.METHOD, Reminders.METHOD_DEFAULT);
                    startActivity(intent);
            } else {
                Intent intent = new Intent(Intent.ACTION_EDIT);
                intent.setType("vnd.android.cursor.item/event");
                intent.putExtra("title", "Title");
                intent.putExtra("description", "Description");
                intent.putExtra("beginTime", startMillis);
                intent.putExtra("allDay", false);
                intent.putExtra("endTime", endTime.endMillis);
                intent.putExtra("eventLocation", "Location");
                intent.putExtra("hasAlarm", 1);
                startActivity(intent);
            }               
        }
    });     
}

推荐答案

你得到的事实

未找到处理 Intent 的 Activity { act=android.intent.action.EDITtyp=vnd.android.cursor.item/event

No Activity found to handle Intent { act=android.intent.action.EDIT typ=vnd.android.cursor.item/event

使用该特定设备意味着没有在其上注册的应用程序可以处理该意图.时期.

with that particular device implies that there's no application registered on it that can handle the intent. Period.

您能做的最好的事情是捕获异常并向用户显示一条消息,告诉用户无法在他/她的设备上处理该操作.

The best you can do is to catch the exception and show the user a message telling that there's no way to handle that operation on his/her device.

您可以做的其他事情是建议安装一个可以处理它的应用程序,即日历类型的应用程序.

Other thing you can do is suggest to install an app that can handle it, namely a calendar type of app.

这篇关于在运行 2.3 的设备上测试时出现 ActivityNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆