English 中文(简体)
使用Intent从另一个程序调用活动会导致权限被拒绝
原标题:Using a Intent to call an activity from another program results in Permission Denied

在我非常简单的应用程序中(基于默认的Hello World应用程序,但添加了一个按钮),我尝试打开我的一部手机(SE X10 Mini)预装的活动,如下所示:

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

但是,它不起作用,我在日志中得到以下错误:

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)

对此我能做些什么吗?或者这种类型的代码是否定的吗?当我在网上搜索时,我看到人们在我认为是他们自己的应用程序中更改意向过滤器,但我显然无法更改预装应用程序中的任何内容。

欢迎有任何想法!

PS。我试图实现的是创建一个小程序,直接启动我手机的“新应用程序”活动,以避免经历两个额外的活动(启动默认日历,单击一天,单击一小时)。

问题回答

马蒂亚斯,

你想做的其实很简单。然而,您需要的信息可能很难获得。你需要找到三条信息(其中没有一条需要重写预装的应用程序)

1)Determine if the activity can be started by external components. This is done by using the Package Manager to provide you a list of all installed packages and their related data. You could also get a free package analyzer from the Android Market. 2)Get the permission required to start the app and add it to your manifest. Permissions are registered with Android OS, but getting required permissions for an external app is not done through the package manager, as far as I know. 3)Get the Intent Extras (data) required to start the activity if it is a "sub activity".

你对#2&;3是联系索尼爱立信或在他们的网站上搜索。许多安卓手机制造商确实提供了有关其产品的公开信息。如果你幸运的话,这可能很简单,比如包括他们通过AIDL提供给你的文件。

模糊逻辑

您必须在清单中列出android.permission.READ_CALENDAR权限。可能还需要其他一些。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签