Run Android App from Chrome
As Google Developer, we can run Android Application from Chrome(Google Developer).
iOS has just same feature using Safari.
Prepare Android Application
You need to change AndroidManifest.xml
The following is example of MainActivity.
<activity android:label="@string/app_name" android:name="com.atmarkplant.webapp.MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Holo.NoActionBar"> <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="key" android:host="application" android:path="/"/> </intent-filter> </activity>
Prepare URL
Create link in any server you have.
The link is
<a href="intent://application/#Intent;scheme=key;package=com.atmarkplant.webapp;end"> Start Web App </a>
Style is
intent: HOST/URI-path // Optional host #Intent; package=[string]; action=[string]; category=[string]; component=[string]; scheme=[string]; end;
In this example, application is HOT/URI, schema is key, package is com.atmarkplant.webapp
These settings are in
How to run?
Open your Chrome and access your server and touch link.
You can see opening application.
How to pass parameters
You change link like that
<a href="intent://application/#Intent;scheme=key;package=com.atmarkplant.webapp;S.key1=value1;S.key2=value2;end"> Start Web App </a>
About parameter, stackoverflow explains alot
How to get parameters
I think onCreate, onStart, onResume are fine.
Intent intent = getIntent(); String value1 = intent.getStringExtra("key1"); String value2 = intent.getStringExtra("key2");
The key is to get Intent. If you invoke this application normally, value1, value2 are null.