Soru & Cevap

Facebook Uygulamasına Bağlantı ...

14.10.2016 - 07:32

Merhabalar , bir uygulamadan o kişiye ait facebook adresine link vermek istriyorum. Normal link verebiliyorum ama eğer facebook uygulaması yüklü ise oraya uygulama yüklü değilse website aracılığı ile o facebook sayfasına yönlendirmek istiyorum . Nasıl yapabiliyirim ? 

9 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user samcro
samcro
15.10.2016 - 01:23

 uygulamanın yüklü olup olmadıgını appInstalledorNot methodu ile kontrol edebilirsin, facebook package name com.facebook.katana, appInstalledorNot methoduna bunu yazabilirsin veya başka bir uygulama olursa orasını değitirebilirsin. getopenfacebookintent methoduda geriye intent döndürüyor kişinin profilini burada veriyorsun. 

public static Intent getOpenFacebookIntent(Context context) {

    try {
        context.getPackageManager()
                .getPackageInfo("com.facebook.katana", 0); 
        return new Intent(Intent.ACTION_VIEW,
                Uri.parse("fb://profile/254175194653125")); 
    } catch (Exception e) {
        return new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://www.facebook.com/arkverse")); 
    }
}

 

public class Example extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        boolean installed = appInstalledOrNot("com.Ch.Example.pack");  
        if(installed) {
            Intent LaunchIntent = getPackageManager()
                .getLaunchIntentForPackage("com.Ch.Example.pack");
            startActivity(LaunchIntent);
            System.out.println("uygulama yüklü");         
        } else {
            System.out.println("uygulama yüklü değil");
        }
    }

    private boolean appInstalledOrNot(String uri) {
        PackageManager pm = getPackageManager();
        boolean app_installed;
        try {
            pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
            app_installed = true;
        }
        catch (PackageManager.NameNotFoundException e) {
            app_installed = false;
        }
        return app_installed;
    }
}

 

Duran Dayıoğlu
16.10.2016 - 04:09
Çok Teşekkür ederim Hocam.
Volkan
16.10.2016 - 01:34
Ne demek umarım iş görmüştür.