Reputation: 181
Whats a easy way of opening a app from my app? The app I'm building I want people to open Foursquare to check in when there at are stores. I have it that they can open the webpage. But i want to open the Foursquare app...
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);
}
});
Updated my question with what worked for me... It will give the user a chose of using the browser or the foursquare app if it is installed on the users phone when they click on the button... After choosing browser or the app, it will bring up a search in foursquare, you can have it search what you want foursquare to search for in the "Place what your searching for hear" portion of the code below.
This is how I set it up, and it works.
Button four = (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);
}
});
Upvotes: 1
Views: 1592
Reputation: 5500
Have a look at the Foursquare documentation for Android intents. It seems like you can use the http URLs as the intent URI to start the native app (and if it is not installed the browser will open the given URL).
Upvotes: 2
Reputation: 13283
The user must have to Foursquare app installed on their device, so think what should happen when they don't. Second the Foursquare app must listen to specific intents to catch your request, if the Foursquare app listens to http requests then this might work. but it really depends on the implementation of the target app if it can handle your request.
I am not sure if it would work to directly call the right activity of Foursquare with the right values in the intent, first i would check their website if they have some documentation how to communicate with their Foursquare app on Android.
Upvotes: 1