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

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

问题描述

我已经成功添加事件到本机的日历,以及为Android API级别14或更高。

工作正常

我试图@ VishalKhakhkhar的code,但我仍然没有能够解决这个问题?我得到的错误:无活动处理意向{行动= android.intent.action.EDIT典型值= vnd.android.cursor.item /事件的设备上测试运行2.3.6当

看我的更新code以下,尝试解决此问题: -

 按钮btnEvents =(按钮)findViewById(R.id.button1);
    btnEvents.setOnClickListener(新OnClickListener(){

        @覆盖
        公共无效的onClick(查看为arg0){
            // TODO自动生成方法存根

            长startMillis = 0;
            长endMillis = 0;
            日历BEGINTIME = Calendar.getInstance();
            beginTime.set(2014,1,16,16,0);
            startMillis = beginTime.getTimeInMillis();
            日历endTime的= Calendar.getInstance();
            endTime.set(2014年,1,16,22,30);
            endMillis = endTime.getTimeInMillis();

            如果(Build.VERSION.SDK_INT> = 14){
                意向意图=新的意图(Intent.ACTION_EDIT).setData(Events.CONTENT_URI)
                    .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,startMillis)
                    .putExtra(CalendarContract.EXTRA_EVENT_END_TIME,endMillis)
                    .putExtra(Events.TITLE,标题)
                    .putExtra(Events.DESCRIPTION,说明)
                    .putExtra(Events.EVENT_LOCATION,位置)
                    .putExtra(Reminders.HAS_ALARM,真)
                    .putExtra(Reminders.METHOD,Reminders.METHOD_DEFAULT);
                    startActivity(意向);
            } 其他 {
                意向意图=新的意图(Intent.ACTION_EDIT);
                intent.setType(vnd.android.cursor.item /事件);
                intent.putExtra(标题,标题);
                intent.putExtra(说明,说明);
                intent.putExtra(BEGINTIME,startMillis);
                intent.putExtra(allDay,假);
                intent.putExtra(endTime的,endTime.endMillis);
                intent.putExtra(eventLocation,位置);
                intent.putExtra(hasAlarm,1);
                startActivity(意向);
            }
        }
    });
}
 

解决方案

试试这个

 如果(Build.VERSION.SDK_INT> = 14){
    意向意图=新的意图(Intent.ACTION_EDIT).setData(Events.CONTENT_URI)
        .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,beginTime.getTimeInMillis())
        .putExtra(CalendarContract.EXTRA_EVENT_END_TIME,endTime.getTimeInMillis())。putExtra(Events.TITLE,eventName的)
        .putExtra(Events.DESCRIPTION,strDesctription)
        .putExtra(Events.EVENT_LOCATION,eventLoc).putExtra(Events.AVAILABILITY,Events.AVAILABILITY_BUSY)
        .putExtra(Reminders.HAS_ALARM,真).putExtra(Reminders.METHOD,Reminders.METHOD_DEFAULT).putExtra(Reminders.DURATION,45)
        .putExtra(Reminders.MINUTES,60);
        mContext.startActivity(意向);
} 其他 {
    意向意图=新的意图(Intent.ACTION_EDIT);
    intent.setType(vnd.android.cursor.item /事件);
    intent.putExtra(标题,eventName的);
    intent.putExtra(说明,strDesctription);
    intent.putExtra(BEGINTIME,beginTime.getTimeInMillis());
    intent.putExtra(allDay,假);
    intent.putExtra(endTime的,endTime.getTimeInMillis());
    intent.putExtra(eventLocation,eventLoc);
    intent.putExtra(hasAlarm,1);
    mContext.startActivity(意向);
}
 

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

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);
            }               
        }
    });     
}

解决方案

Try with this

if (Build.VERSION.SDK_INT >= 14) {
    Intent intent = new Intent(Intent.ACTION_EDIT).setData(Events.CONTENT_URI)
        .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis())
        .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()).putExtra(Events.TITLE, eventname)
        .putExtra(Events.DESCRIPTION, strDesctription)
        .putExtra(Events.EVENT_LOCATION, eventLoc).putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY)
        .putExtra(Reminders.HAS_ALARM, true).putExtra(Reminders.METHOD, Reminders.METHOD_DEFAULT).putExtra(Reminders.DURATION, 45)
        .putExtra(Reminders.MINUTES, 60);
        mContext.startActivity(intent);
} else {
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setType("vnd.android.cursor.item/event");
    intent.putExtra("title", eventname);
    intent.putExtra("description", strDesctription);
    intent.putExtra("beginTime", beginTime.getTimeInMillis());
    intent.putExtra("allDay", false);
    intent.putExtra("endTime", endTime.getTimeInMillis());
    intent.putExtra("eventLocation", eventLoc);
    intent.putExtra("hasAlarm", 1);
    mContext.startActivity(intent);
}

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

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