0

我已經與TabGroupActivity(See this for example)的Android應用程序,一切工作正常,除了社交網絡整合Facebook和Twitter等。社會融合不是在Android應用程序正與TabGroupActivity

此錯誤被記錄在#1前hereherehere

java.lang.RuntimeException: Unable to resume activity {com.xxxx.xxxxx/com.facebook.LoginActivity}: com.facebook.FacebookException: Cannot call LoginActivity with a null calling package. This can occur if the launchMode of the caller is singleInstance. 

07-29 18:22:55.757: E/AndroidRuntime(2342): Caused by: com.facebook.FacebookException: Cannot call LoginActivity with a null calling package. This can occur if the launchMode of the caller is singleInstance. 

PS:清單文件我更新的代碼如下:一切都實現TabGroupActivity

更新1之前工作得很好as:

<activity 
     android:name="com.facebook.LoginActivity" 
     android:label="@string/com_facebook_loginview_log_in_button" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" 
     android:launchMode="singleTask" /> 

但異常仍然給:the launchMode of the caller is singleInstance

爲什麼這麼..?

UPDATE 2:現在我在Facebook SDK的LoginActivity裏面保留了調試點。在對於getCallingPackage(),我得到

String callingPackage = getCallingPackage();//Always Null 


BackTracing it: On the Calling Activity (FacebookShare.java), I always get data as null instead of some values. 

@Override 
    public void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 
     Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); 
     //Toast.makeText(FacebookShareActivity.this, "onActivityResult", Toast.LENGTH_SHORT).show(); 
    } 

任何人都可以解釋這種現象..?我一直在堅持這一點。

+0

你在做什麼?我的意思是你想做只在社交網站上分享? –

+0

@ JellyBean-是的..我有一些信息,我想與Facebook分享(意味着更新我的狀態)。並且在實現TabGroupActivity之前一切都很好。所以wat可能是解決方案嗎? –

回答

1

我最後一次這樣的錯誤,那是因爲我推出Facebook的與錯誤的參數LoginActivity,使用XML的這一部分:

<activity 
     android:name="com.facebook.LoginActivity" 
     android:label="@string/app_name" 
     android:theme="@android:style/Theme.Translucent.NoTitleBar" /> 

我有這個錯誤,當我與launchMode singleInstance推出LoginActivity(或類似的東西)。看一下這個。

編輯: 我還有一個想法...當你嘗試調用facebook傳遞上下文而不是本地活動(一個在標籤中),但嘗試傳遞父活動的上下文(它將是TagGroupActivity)。

+0

我得到了以下異常:07-29 16:27:04.225:E/AndroidRuntime(7461):了java.lang.RuntimeException:無法恢復活動{} com.xxxx.xxx/com.facebook.LoginActivity:com.facebook。 FacebookException:無法使用空調用程序包調用LoginActivity。如果調用者的launchMode是singleInstance,則會發生這種情況。 –

+0

關於ManifestFile ::

+0

我我的答案更新,現在看看這個 – Drake29a

0
<activity 
    android:name="xx.yy.YourActivity" 
    android:launchMode="singleTask" 
/> 

(試行singleTask而不是singleInstance) 我在過去同樣的問題,但我重新檢查我的清單,並不能找到任何launchMode那裏。

+0

我喜歡它:但仍然給出相同的例外 –

2

粘貼此code.It正在研究這些應用程序安裝在手機烏爾。

void share(String nameApp, String imagePath) { 
      try 
      { 
       List<Intent> targetedShareIntents = new ArrayList<Intent>(); 
       Intent share = new Intent(android.content.Intent.ACTION_SEND); 
       share.setType("image/jpeg"); 
       List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(share, 0); 
       if (!resInfo.isEmpty()){ 
        for (ResolveInfo info : resInfo) { 
         Intent targetedShare = new Intent(android.content.Intent.ACTION_SEND); 
         targetedShare.setType("image/jpeg"); // put here your mime type 
         if (info.activityInfo.packageName.toLowerCase().contains(nameApp) || info.activityInfo.name.toLowerCase().contains(nameApp)) { 
          targetedShare.putExtra(Intent.EXTRA_SUBJECT, "Sample Photo"); 
         targetedShare.putExtra(Intent.EXTRA_TEXT,"This photo is created by App Name"); 
          targetedShare.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath))); 
          targetedShare.setPackage(info.activityInfo.packageName); 
          targetedShareIntents.add(targetedShare); 
         } 
        } 
        Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Select app to share"); 
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{})); 
        startActivity(chooserIntent); 
       } 
      } 
      catch(Exception e){ 
       Log.v("VM","Exception while sending image on" + nameApp + " "+ e.getMessage()); 
      } 
      } 
+0

否..我不能讓它工作像這樣..我已經有Fa的按鈕了cebook,Twitter等。你可以推薦我一些其他的解決方案,請參閱我的更新後的帖子。 –