views:

32

answers:

1

In my very simple app (based on the default Hello World app but with a button added) I try to open one of my phone's (a SE X10 Mini) preinstalled activities, like this:

Intent calendarIntent = new Intent();
calendarIntent.setClassName("com.sonyericsson.calendar","com.sonyericsson.calendar.dayview.DayActivity");
startActivity(calendarIntent);

However, it does not work, I get the following error in the log:

E/AndroidRuntime( 2215): java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.sonyericsson.calendar/.dayview.DayActivity } from ProcessRecord{302cf238 2215:com.klibb.quickappointment/10079} (pid=2215, uid=10079) requires null
E/AndroidRuntime( 2215):    at android.os.Parcel.readException(Parcel.java:1246)
E/AndroidRuntime( 2215):    at android.os.Parcel.readException(Parcel.java:1234)
E/AndroidRuntime( 2215):    at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1157)
E/AndroidRuntime( 2215):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1449)
E/AndroidRuntime( 2215):    at android.app.Activity.startActivityForResult(Activity.java:2661)
E/AndroidRuntime( 2215):    at android.app.Activity.startActivity(Activity.java:2705)
E/AndroidRuntime( 2215):    at com.klibb.quickappointment.QuickAppointmentActivity$1.onClick(QuickAppointmentActivity.java:25)

Is there anything I can do about this or is this type of code a no-no? When searching the web I see people changing the intent filters in what I assume is their own app, but I obviously cannot change anything in a preinstalled app.

Any ideas are welcome!

PS. What I am trying to achieve is to create a small program that directly launches the "New Apppointment" activity of my phone, to avoid going through two extra activities (start the default calendar, click a day, click an hour).

A: 

You have to have android.permission.READ_CALENDAR permission listed in the manifest. Some others may be required as well.

Asahi
Thanks for this idea! I added the following to the manifest file but there is no difference: <uses-permission android:name="android.permission.READ_CALENDAR" />
Mathias Dahl