Android - Opening another app using Custom URL Scheme does not work for all external apps? - android

I am trying to launch other apps from my app by passing the custom URL scheme for the app to be launched, some of the apps are launched successfully and some failed.
Method has been defined in custom created plugin for a cordova app.
Tried launching following URL schemes :-
"ms-outlook://" - Success
"ms-outlook://compose?" - Failed
"instagram://" - Failed
"instagram://app" - Failed
"fb://" - Opens either in foreground or background
"googlegmail://" - Failed (Read somewhere that gmail URL scheme isn't supported in android)
"googlegmail://co?" - Failed
public void myMethod(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
Context appContext = cordova.getActivity().getApplicationContext();
if (intent.resolveActivity(appContext.getPackageManager()) != null) {
} else {
Toast.makeText(appContext, "No activity found", Toast.LENGTH_LONG).show();
Is there anything wrong with these schemes or something I am missing in the method defined ??
Expected result is to launch specified app from custom URL scheme directly if the app is installed without showing any Intent chooser popup.
Any help would be grateful !!


Launch Twitter app from another app in Android

I'm trying to launch Twitter app from my Cordova app on Android but it always open inapp browser, i use the same code on IOS and it work perfectly.
This is the code i'm using:'twitter://user?screen_name=MyTwitterUserName', '_system');
Before i execute the above code i check if Twitter app is already installed, i have installed it on my phone but still open it in browser, the same code as i said before works without any problem on IOS, i also tried this code but none of them works on Android.'twitter://user?user_id=MyTwitterID', '_system');
This should launch the Twitter app.
Intent intent = null;
try {
// get the Twitter app if possible
this.getPackageManager().getPackageInfo("", 0);
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?user_id=USERID"));
} catch (Exception e) {
// no Twitter app, revert to browser
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(""));
Try using this plugin, too:

Let custom URL fall back to search in Play Store

Imagine you have a custom URL handler registered in your Android app. Some other app / webpage contains a link with an URL that would be recognized by this handler, but unfortunately the app is not yet installed on the user's device. Does the developer of the app has any options to hint Google's Play Store to find your app in the Play Store by searching for this URL scheme and installing this particular app or is the user basically lost with the "no activity found to handle this intent" problem?
You can use PackageManager.resolveActivity() to check if that particular app is installed:
Uri customUri = Uri.parse("mycustomhandler://my.custom.encoded.URI");
Intent customIntent = new Intent(Intent.ACTION_VIEW, customUri);
if (getPackageManager().resolveActivity(customIntent, 0) == null) {
// The package is not installed,
// implement your logic here

How can I Launch Facebook App from my App? [duplicate]

Possible Duplicate:
launch facebook app from other app
I want to open the Facebook app out of my own App using a scheme url. But I dont know how to do that. My scheme url looks like this: fb://page/133105433423897. Maybe via inent and/or parseUri. Any Idea?
check out following post describing similar problem:
URL to open facebook app in android
copied for quick reference:
You need to use Intents. Here's how to call the FB application (if it is installed):
Intent intent = new Intent();
intent.putExtra("client_id", applicationId);
mAuthActivityCode = activityCode;
activity.startActivityForResult(intent, activityCode);

Opening a facebook web profile via facebook app doesn't always work

i'm trying to open a specific profile page on the facebook app (when facebook app is installed of course).
The problem
I've noticed that if I, as an end user, go to the app info screen (where i can uninstall the app, clear its cache etc...) of facebook app and choose "force stop", and then try to open the profile page, the facebook app itself either crashes or doesn't even start.
if the facebook app was already running, the code works fine.
The code
context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
final String facebookScheme = String.format("fb://profile/%s", socialNetworkUid);
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(facebookScheme));
return intent;
BTW, the scheme was found from this link.
The question
why does it occur?
can i somehow avoid it?
is it a bug on facebook app or maybe i didn't implement it correctly?
do I really need now to check if FB app is active and only then allow to use this intent? if so, how?
The following code works for me with no issue, whether the Facebook app is open or not.
public void goToFacebook(String id) {
try {
getPackageManager().getPackageInfo("com.facebook.katana", 0);
Intent facebookPage = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/"+id));
} catch (Exception e) {
Intent launchBrowser = new Intent(Intent.ACTION_VIEW, Uri.parse(""+id));
As you can see, I am using try/catch to detect whether or not the FB app is installed. If the Facebook app is already launched, it will move to the profile, otherwise it will launch the app and then open the profile.
If the Facebook app isn't installed, I send the user to the profile page in a browser.
I've managed to reproduce the same thing you are seeing on my test device after multiple opens of the Facebook app from within my app. I can see the following error in LogCat, so it does appear to be a bug with the Facebook app:
10-10 14:43:01.406: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.katana/com.facebook.katana.IntentUriHandler}: java.lang.IllegalStateException: FbSharedPreferences used before initialized

Android: how can I test the “Open With” feature on an emulator if legally I can't install multiple apps that will trigger the Open With window?

As the title states.
How would you tackle this?
I don't feel like hacking Android to install the marketplace & multiple apps.
But on the other hand, I do have to test the "Open With" feature of my application, which I'm currently unable to trigger as there are no 2 same apps to open some sort of file.
Note: I don't have a real phone with me.
Code that I'm referring to is this (when a user clicks a file):
Intent intnt = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(f);
String mime = General.getMimeType(full_path);
intnt.setDataAndType(uri, mime);
try {
} catch (ActivityNotFoundException e) {
"No Application Available to View ...",
Basicaly the problem is that currently when I click an image/music file, the app automatically starts (no Open WIth window).
And I can't disable the default app for these files as they're the only applications that can run them.
You can use mime type */* and it will show you the open with window:
intnt.setDataAndType(uri, "*/*");
with all installed applications.
Create a test application that responds to an ACTION_VIEW Intent for the desired MIME type, and install it on the device.
Or, find open source applications that can respond to an ACTION_VIEW Intent for the desired MIME type, and install those on the device.