2012-05-13 95 views
1

從我的應用程序打開應用程序的簡單方法是什麼?我正在建設的應用程序希望人們在有商店時打開Foursquare進行檢查。我知道他們可以打開網頁。但我想打開Foursquare應用程序...從我的應用程序打開Foursquare應用程序

four.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View view) { 
      // TODO Auto-generated method stub 
      Uri uriUrl = Uri.parse("https://m.foursquare.com/nationalcleaners"); 
      Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); 
      startActivity(launchBrowser); 
     } 
    }); 

更新我與我工作的問題... 它會給如果已安裝在其上的用戶選擇使用瀏覽器或Foursquare應用程序的用戶點擊按鈕時的電話......選擇瀏覽器或應用程序後,它會調出foursquare的搜索結果,您可以讓它搜索您想要的foursquare在「放置您尋找的內容」中搜索的內容。部分代碼如下。

這是我如何設置它,它的工作原理。

按鈕四=(Button)findViewById(R.id.foursq);

four.setOnClickListener(new View.OnClickListener() { 

     public void onClick(View view) { 
      // TODO Auto-generated method stub 
      Uri uriUrl = Uri.parse("http://m.foursquare.com/search?q=Place what your searching for hear"); 
      Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl); 
      startActivity(launchBrowser); 
     } 
    }); 
+1

也許這線程是你 http://stackoverflow.com/questions/3872063/android-launch-an-application-from-another-application – Xuphey

+0

感謝有用的,你將如何找到「com.package。地址「名稱的Foursquare應用程序? – KodiakBear211

+0

這是Foursquare應用「com.joelapenna.foursquared」的包名稱,謝謝... – KodiakBear211

回答

2

查看針對Android意圖的Foursquare documentation。您似乎可以使用http URL作爲意向URI來啓動本機應用程序(如果未安裝,瀏覽器將打開給定的URL)。

+0

這有幫助!謝謝!!! – KodiakBear211

+0

@ KodiakBear211如果有幫助,請隨時接受答案;) – johlo

1

用戶必須在他們的設備上安裝Foursquare應用程序,所以想想他們不應該發生什麼。 其次Foursquare應用程序必須監聽特定的意圖來捕捉您的請求,如果Foursquare應用程序監聽http請求,那麼這可能會起作用。但它確實取決於目標應用程序的實現,如果它可以處理您的請求。

我不知道它是否會直接調用正確的Foursquare活動的意圖的價值,首先我會檢查他們的網站,如果他們有一些文件如何與他們的Android上的Foursquare應用程序進行通信。

+0

我試過了我的手機。當應用程序安裝它的作品。安裝應用程序時,它強制關閉。我該怎麼辦? – KodiakBear211

+0

這是我用 – KodiakBear211

+0

four.setOnClickListener代碼(新View.OnClickListener(){ \t \t \t \t \t \t公共無效的onClick(查看視圖){ \t \t \t \t // TODO自動生成方法存根 \t \t \t \t意圖LaunchIntent = getPackageManager()getLaunchIntentForPackage( 「com.joelapenna.foursquared」);。 \t \t \t \t startActivity(LaunchIntent) ; \t \t \t} \t \t}); – KodiakBear211

相關問題