1

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); 
        }
    });
johlo
  • 5,182
  • 1
  • 16
  • 31
KodiakBear211
  • 181
  • 2
  • 3
  • 13

2 Answers2

2

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).

johlo
  • 5,182
  • 1
  • 16
  • 31
1

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.

Simon
  • 12,485
  • 14
  • 63
  • 84
  • I've tried it on my phone. When the app is installed it works. When the app ant installed it force closes. What should i do? – KodiakBear211 May 13 '12 at 21:19
  • four.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { // TODO Auto-generated method stub Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.joelapenna.foursquared"); startActivity( LaunchIntent ); } }); – KodiakBear211 May 13 '12 at 21:20