Open Android App with custom URL scheme - android

this questions has been asked in a similar way like a hundred times, though I still cannot find a proper answer to get my app to work the way I want. Maybe this is not possible which would be a valid answer of course.
I have an activity defined as follows in my app:
<activity
android:name="MyActivity"
android:label="MyActivityLabel"
android:launchMode="singleTask" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="MyActivityCustomUrlScheme" />
</intent-filter>
</activity>
When I start my App in the emulator and then open the browser and type a URL like:
MyActivityCustomUrlScheme://mycustomHost.com?someOptions
the only thing happening is that chrome tries googling for it, which is not what I want. If I send myself an SMS with this scheme, the scheme inside is not recognised as such and not clickable :(
I want to do that, because I already have an iOS App in the store, which uses the scheme MyActivityCustomUrlScheme://mycustomHost.com?someOptions and it would be a lot of hazel to change it everywhere, as users get this url send by email or SMS. I'd be really thankful if someone can help me out on this problem.

Try to use definition of host :
<activity android:name="MyActivity"
android:label="MyActivityLabel"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="MyActivityCustomUrlScheme" android:host="mycustomHost.com" />
</intent-filter>
</activity>

Related

Application not being displayed in the list of default apps on device

I am trying to write a photo viewer application and have put the below in my Manifest file
<activity
android:name="com.example.testimageintent.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW">
<category android:name="android.intent.category.DEFAULT">
<data android:mimeType="image/*"/>
</category>
</action>
</intent-filter>
</activity>
The idea was to list this app in the list of available applications when the user tries to open an image from the file browser.
Somehow my app is never listed in that list. I can still see the gallery and other apps in the list but my app never appears.
Any pointers to what i might be doing wrong?
I think you are missing
<action android:name="android.intent.action.SEND" />
in your <intent-filter>
Define it to look like this:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*"/>
</intent-filter>
Sorry Guys, it's my mistake. I have nested the Action, Category and the Data blocks.
They should be independent of each other.
It works fine once i have them as individual tags like below:
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/*"/>

Link from Android browser to my application not working

I want from the android browser be able to launch my application if it's installed, or launch my website in the other case.
So in order to make it work, I put :
<activity android:name=".MMLogin" android:label="MeetMe" android:theme="#android:style/Theme.NoTitleBar" android:screenOrientation="portrait">
<intent-filter>
<data android:scheme="http" android:host="meet-me.com" android:path="/signin" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
in the Manifest, and I created a dummy link to test; and it's not working.
I've tried with and without: BROWSABLE and DEFAULT
I've tried with meetme://datas and change the scheme; nothing worked.
I used threads on stackoverflow like :
Launch custom android application from android browser
What am I doing wrong, or is there a special thing to do to make it work ?
My application suppports from API 7.
Cheers
I used :
Intent Filter to Launch My Activity when custom URI is clicked, I think what was missing is this block :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/myapp" />
</intent-filter>

Android Intent-Filter for Multi Screen

I want to launch my application from web browser in Android using Intent-Filter based on scheme, host in the DATA tag like this.
<activity android:name=".activity.LogoActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activity.phone.MainActivityPhone" android:configChanges="orientation|keyboard"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="my" android:host="mystore" />
</intent-filter>
</activity>
<activity android:name=".activity.tablet.MainActivityTablet" android:configChanges="orientation|keyboard"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="my" android:host="mystore" />
</intent-filter>
</activity>
As you see, There are two Main Activities for phone and tablet, and in LogoActivity determine which Main Activity will be opened by screen size. But the problem is when user clicks my://mystore link in web browser, there are two choices to launch that MainActivtyPhone and MainActivityTablet.
What I want is there is only one proper intent-filter works for uri my://mystore .
Any help? Thanks.
On the first run of your application, use PackageManager to disable the activity you do not want to use.
Please do not invent custom schemes. Please use HTTP URLs instead:
<data android:scheme="http" android:host="yourdomain.com" android:path="/something/or/another" />
That way, you can actually put a real Web page at http://yourdomain.com/something/or/another, so if somebody gets your link but does not have your app installed, they will see your Web page, instead of getting an error.
Also, please remove android:configChanges, or handle all configuration changes.

Could not launch application by calling a URL from Android Browser

There are many answers in stackoverflow showing how to lauch app from a web browser ,but I am not sure what went wrong with my code, that never seems to be doing the intended.
I am trying to launch my app by a URL from any other app like web browser,initially
my manifest file looks like this
<activity android:name=".Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="http" android:host="ebay.com" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
And When I typed http://ebay.com in the browser that never started my app.Obviously,how does the browser know about my app?,then i tried the other way around and added another Activity called MyActivity and altered the manifest file as
<activity android:name=".Main">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MyActivity">
<intent-filter>
<data android:scheme="http" android:host="ebay.com" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
and tried in my Main Activity
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://mycityway.com")));
Thus producing the intended result.I can also start another application Activity using this method.
But most of the answers here says that the later is possible.What is the mistake i am doing,I couldn't launch my app from browser.Please guide me.
And When I typed http://ebay.com in the browser that never started my
app.
It gets started when a matching link is clicked not when you type the url in the browser.
Try it by sending yourself an email containing http://ebay.com and click the link in the email application.

How to start app from Android browser, when I type in "myapp://" in address bar

I need the browser to start my app whenever I enter the "myapp://blah.com/a?b=1&c=2" in the browser. I have searched a lot on this topic, but non of the answers really helped me. Could you please help to understand what I'm missing?
<activity android:name=".MyAppMain"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
After installation from Eclipse (Run As Android application) my app can work ok on its own, but when I type in "myapp://blah.com/a?b=1&c=2", the browser is simply googling for this string. Could you point out what else I'm missing? Do I need after installation to somehow register in the system that I want to handle "myapp://" urls?
I have done this using the
<activity android:name=".ReceiveInviteActivity">
<intent-filter >
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:scheme="appname"
android:host="project.example.com"
/>
</intent-filter>
</activity>
And activity
if (Intent.ACTION_VIEW.equals(action)) {
final List<String> segments = intent.getData().getPathSegments();
Log.d("LISTARRAY",segments.toString());
String idString = segments.get(0);
Log.d("LISTITEM",segments.get(0).getClass().toString());
String friendId = idString.substring((idString.indexOf("="))+1);
Log.d("friendId!",friendId);
I hope this will help you.
Check out this answer for why it isn't working: Android custom URI scheme incorrectly encoded when type in browser
Basically, the default Android browser only accepts certain URI schemes, so your custom one won't work when typed directly into the URL bar.

Categories

Resources