我的整个想法有点复杂,但只是为了解决问题,所以它们很简单,而且在这里......我在窗口小部件上有一个按钮,我需要打开“场所”活动官方的Facebook应用程序。
这是我正在使用的代码:
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中收到此错误:
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);
一切都很有效,它打开了家庭活动,但这并不是我想要做的事情。
我试过
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中看到的内容:
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 }
所以,这让你有点了解我如何获取我的信息。
答案 0 :(得分:1)
我不同意CommonsWare的回答。答案也完全没有被接受,虽然我认为答案是正确的,然后我尝试了下面的代码,发现你可以使用以下代码从另一个应用程序打开Activity!...
appAction = Intent.ACTION_VIEW;
appPackage = "com.facebook.katana";
appActivity = "com.facebook.katana.IntentUriHandler";
data = Uri.parse("facebook:/places").buildUpon().appendQueryParameter("user", Long.toString(post.getSourceId())).appendQueryParameter("post", post.getPostId()).build();
Intent intent = new Intent(appAction);
intent.setClassName(appPackage, appActivity);
intent.setData(data);
ctx.startActivity(intent);
答案 1 :(得分:0)
我在小部件上有一个按钮,我需要在官方的Facebook应用程序中打开“地点”活动。
由于Facebook似乎不支持以这种方式与他们的Android应用程序集成,请不要这样做。
Permission denied: checkComponentPermission() reqUid=10055
该活动只能由Facebook启动。