拒绝外部活动的意图

我的整个想法有点复杂,但只是为了把事情分解,这样它们就很简单了……我在一个小部件上有一个按钮,我需要在官方脸书应用.

My whole idea is a little more complex, but just to break things down so they're simple and to the point here...I have a button on a widget that i need to open the "places" activity in the official facebook app.

这是我正在使用的代码:

Here's the code i'm using:

 Intent PlacesIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("com.facebook.katana", "com.facebook.katana.activity.places.PlacesNearbyActivity"));
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, PlacesIntent, 0);
            views.setOnClickPendingIntent(R.id.places, pendingIntent);

我在 logcat 中收到此错误:

I get this error in the logcat:

 11-06 22:26:48.117: WARN/ActivityManager(85): Permission denied: checkComponentPermission() reqUid=10055
    11-06 22:26:48.117: WARN/ActivityManager(85): Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.facebook.katana/.activity.places.PlacesNearbyActivity bnds=[371,129][428,203] } from null (pid=-1, uid=10157) requires null
    11-06 22:26:48.127: WARN/ActivityManager(85): Unable to send startActivity intent
    11-06 22:26:48.127: WARN/ActivityManager(85): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.facebook.katana/.activity.places.PlacesNearbyActivity bnds=[371,129][428,203] } from null (pid=-1, uid=10157) requires null
    11-06 22:26:48.127: WARN/ActivityManager(85):     at com.android.server.am.ActivityManagerService.startActivityLocked(ActivityManagerService.java:3223)
    11-06 22:26:48.127: WARN/ActivityManager(85):     at com.android.server.am.ActivityManagerService.startActivityInPackage(ActivityManagerService.java:3980)
    11-06 22:26:48.127: WARN/ActivityManager(85):     at com.android.server.am.PendingIntentRecord.sendInner(PendingIntentRecord.java:212)
    11-06 22:26:48.127: WARN/ActivityManager(85):     at com.android.server.am.ActivityManagerService.startActivityIntentSender(ActivityManagerService.java:3843)
    11-06 22:26:48.127: WARN/ActivityManager(85):     at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:210)
    11-06 22:26:48.127: WARN/ActivityManager(85):     at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1480)
    11-06 22:26:48.127: WARN/ActivityManager(85):     at android.os.Binder.execTransact(Binder.java:288)
    11-06 22:26:48.127: WARN/ActivityManager(85):     at dalvik.system.NativeStart.run(Native Method)

如果我使用,

Intent PlacesIntent1 = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("com.facebook.katana", "com.facebook.katana.HomeActivity"));
            PendingIntent pendingIntent1 = PendingIntent.getActivity(context, 0, PlacesIntent1, 0);
            views.setOnClickPendingIntent(R.id.facebook, pendingIntent1);

一切都很好,它打开了家庭活动,但这并不是我真正想要做的.

Everything works great and it opens the home activity, but that's not really what i'm trying to do.

我试过了

com.facebook.katana.activity.places.PlacesNearbyActivity - I actually see a respons in the logcat about the denail with this one
com.facebook.katana.activity.PlacesNearbyActivity
com.facebook.katana.places.PlacesNearbyActivity
com.facebook.katana.PlacesNearbyActivity

其他人什么都没有发生

以下是我在手机上手动打开活动时在 logcat 中看到的内容:

Here's what i see in the logcat when manually opening the activities on my phone:

11-06 20:20:38.295: INFO/ActivityManager(85): Starting activity: Intent { cmp=com.facebook.katana/.activity.places.PlacesNearbyActivity }

11-06 22:03:28.027: INFO/ActivityManager(85): Starting activity: Intent { flg=0x4000000 cmp=com.facebook.katana/.HomeActivity }

所以,这让你知道我是如何获得我的信息的.

So, that gives you sort of an idea how i got my information.

推荐答案

我在一个小部件上有一个按钮,我需要在官方 Facebook 应用程序中打开地点"活动.

I have a button on a widget that i need to open the "places" activity in the official facebook app.

由于 Facebook 似乎不支持以这种方式与其 Android 应用程序集成,因此请不要这样做.

Since it appears that Facebook does not endorse integration with their Android application this way, please do not do this.

Permission denied: checkComponentPermission() reqUid=10055

该活动只能由 Facebook 发起.

That activity can only be started by Facebook.

相关文章