2016-10-17 5 views
1

私はを作成しようとしています。のことを私たちにお尋ねください。私はFacebookのアプリでそのページを開こうと思っています。通常のブラウザ。FacebookのLiteアプリケーションのページを開く方法

"https://www.facebook.com/<my_page_name>" 

OK:これはanswer

private void showPage(String url) { 
     Uri uri = Uri.parse(url); 
     try { 
      ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo("com.facebook.katana", 0); 
      if (applicationInfo.enabled) { 
       uri = Uri.parse("fb://facewebmodal/f?href=" + url); 
      } 
     } catch (PackageManager.NameNotFoundException ignored) { 
      try { 
       ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo("com.facebook.lite", 0); 
       if (applicationInfo.enabled) { 
        uri = Uri.parse("fb://facewebmodal/f?href=" + url); 
       } 
      } catch (PackageManager.NameNotFoundException e) { 
       //do nothing 
      } 
     } 

     startActivity(new Intent(Intent.ACTION_VIEW, uri)); 
    } 

と私は、文字列を使用しているURLに@Jared Rummlerに基づいて、私のコードです。しかし、それは通常のFacebookのアプリにのみ動作します。私はそれがFacebookのLiteのアプリで動作するように変更する必要がある誰も知っている?

私はlogcatに次のエラーをキャッチしています:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.technology.softwares.click.rs, PID: 4086             android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=fb://facewebmodal/f?href=https://www.facebook.com/<my_page_name> 

おかげ

答えて

0
public final void launchFacebook() { 
     final String urlFb = "fb://page/"+pageId; 

     Intent intent = new Intent(Intent.ACTION_VIEW); 
     intent.setData(Uri.parse(urlFb)); 

     // If a Facebook app is installed, use it. Otherwise, launch 
     // a browser 
     final PackageManager packageManager = getPackageManager(); 
     List<ResolveInfo> list = 
       packageManager.queryIntentActivities(intent, 
         PackageManager.MATCH_DEFAULT_ONLY); 
     if (list.size() == 0) { 
      final String urlBrowser = "https://www.facebook.com/pages/"+pageId; 

      intent.setData(Uri.parse(urlBrowser)); 
     } 

     startActivity(intent); 


    } 
+0

こんにちは。通常のFacebookのアプリでも動作しますが、Liteでは動作しません。ありがとう – EmilyR

0

は intent.setPackage( "com.facebook.mlite")を挿入してみてください。 アクティビティを開始する直前に、たとえば

private void showPage(String url) { 
    Uri uri = Uri.parse(url); 
    try { 
     ApplicationInfo applicationInfo = 
getPackageManager().getApplicationInfo("com.facebook.katana", 0); 
     if (applicationInfo.enabled) { 
      uri = Uri.parse("fb://facewebmodal/f?href=" + url); 
     } 
    } catch (PackageManager.NameNotFoundException ignored) { 
     try { 
      ApplicationInfo applicationInfo = getPackageManager().getApplicationInfo("com.facebook.lite", 0); 
      if (applicationInfo.enabled) { 
       uri = Uri.parse("fb://facewebmodal/f?href=" + url); 
      } 
     } catch (PackageManager.NameNotFoundException e) { 
      //do nothing 
     } 
    } 
    Intent intent = new Intent(Intent.ACTION_VIEW, uri); 
    intent.setPackage("com.facebook.mlite"); 
    startActivity(intent); 
} 
+0

logCatで同じエラーを返します。 '原因:android.content.ActivityNotFoundException:Intentを処理するアクティビティが見つかりませんでした' Thx – EmilyR

+0

intent.setPackage( "com.facebook.lite"); – RRTW

関連する問題