How to Register Some Url Namespace (Myapp://App.Start/) for Accessing Your Program by Calling a Url in Browser in Android Os

How to register some URL namespace (myapp://app.start/) for accessing your program by calling a URL in browser in Android OS?

You need to follow the standard rules for URIs via the W3C and such, which basically means: do not do this.

Android defines a Uri syntax for describing a generic Intent. There are methods on Intent for converting to and from this representation, such as: http://developer.android.com/reference/android/content/Intent.html#toUri(int)

So the way to do this is to use the normal facilities to describe an in your manifest for the kinds of intents you are going to handle with a particular component, especially defining an action name in your own namespace (com.mycompany.myapp.action.DO_SOMETHING or whatever). You can then make an Intent that matches your component, and use Intent.toUri() to get the URI representation of this. This can be placed in your link, and will then when pressed look for something that handles and and thus find your app. Note to be launched from the browser like this, the component's must handle the BROWSABLE category. (You don't need to have this in the Intent you put in the link, the browser will automatically add this in for you.)

Finally, you may want to set the package of the intent to your app with this: http://developer.android.com/reference/android/content/Intent.html#setPackage(java.lang.String)

This is a newer feature in the platform, which allows you to direct link intents to only your app so that other applications can not intercept and handle them.

In summary: read the regular documentation on intents and intent filters (such as the NotePad tutorial, though you won't be using content: URIs here, probably just custom actions) and get your app working that way. Then you can make a browser link to launch your app in the same way, provided your intent-filter handles the BROWSABLE category.

How to register some URL namespace (myapp://app.start/) for accessing your program by calling a URL in browser in Android OS?

You need to follow the standard rules for URIs via the W3C and such, which basically means: do not do this.

Android defines a Uri syntax for describing a generic Intent. There are methods on Intent for converting to and from this representation, such as: http://developer.android.com/reference/android/content/Intent.html#toUri(int)

So the way to do this is to use the normal facilities to describe an in your manifest for the kinds of intents you are going to handle with a particular component, especially defining an action name in your own namespace (com.mycompany.myapp.action.DO_SOMETHING or whatever). You can then make an Intent that matches your component, and use Intent.toUri() to get the URI representation of this. This can be placed in your link, and will then when pressed look for something that handles and and thus find your app. Note to be launched from the browser like this, the component's must handle the BROWSABLE category. (You don't need to have this in the Intent you put in the link, the browser will automatically add this in for you.)

Finally, you may want to set the package of the intent to your app with this: http://developer.android.com/reference/android/content/Intent.html#setPackage(java.lang.String)

This is a newer feature in the platform, which allows you to direct link intents to only your app so that other applications can not intercept and handle them.

In summary: read the regular documentation on intents and intent filters (such as the NotePad tutorial, though you won't be using content: URIs here, probably just custom actions) and get your app working that way. Then you can make a browser link to launch your app in the same way, provided your intent-filter handles the BROWSABLE category.

How to launch my application from link if, it installed in device

    Manifest file 

<activity
android:name=".SplashScreenActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" >
</category>
</intent-filter>
<intent-filter android:label="@string/app_name" >
<action android:name="android.intent.action.VIEW" >
</action>

<data
android:host="xxx.com"
android:scheme="http" >
</data>

<category android:name="android.intent.category.DEFAULT" >
</category>
<category android:name="android.intent.category.BROWSABLE" >
</category>
</intent-filter>
</activity>

if want to access url
In activty

try {
Uri intentUri = getIntent().getData();
Log.d(TAG, "Request intentUri: "+intentUri);

} catch (Exception e) {
Log.i(TAG, "Request intentUri: " , e);
}

About starting Android app from an URL

You need to have two <intent-filter> elements for this <activity>. One will be for MAIN and LAUNCHER. The other will be for VIEW, BROWSABLE/DEFAULT, and your <data> element:

<activity android:name=".MyActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<category android:name="android.intent.category.LAUNCHER"></category>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="my.app" android:scheme="http"></data>
</intent-filter>
</activity>

Then, http://my.app should launch your activity.

Adobe Flex Mobile 4.6 - Launching app from browser

Okay...I'm not sure what I did, maybe the break I took for a glass of water helped. But when I just tried it again, it works.

I cleared out the manifest section, and tried again, with the example from this site:

http://dreamingwell.com/articles/archives/2011/06/flex-mobile-cus-2.php

And now it works...but I thought I tried that already...

(Moved from comments to an actual answer, now that StackOverflow is allowing me to do so)



Related Topics



Leave a reply



Submit