Ответ 1
Это то, как приложение Link работает для меня, чтобы делиться с друзьями через Facebook или другие намерения поделиться.
Поделиться кодом намерения
Intent intent=new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "Lets Enjoy");
intent.putExtra(Intent.EXTRA_TEXT, "Lets Enjoy" + "http://myApp.com/id/"+12345);
startActivity(Intent.createChooser(intent, "Share With Friends"));
Android манифест.
<activity
android:name="com.package.youractivitytoopen"
android:theme="@style/MyMaterialTheme"
android:screenOrientation="portrait">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http"
android:host="myApp.com"
android:pathPrefix="/id/" ></data>
</intent-filter>
</activity>
Если вы делитесь данными, вы получите такие данные
Intent intentShare = getIntent();
String action = intentShare.getAction();
Uri data = intentShare.getData();
if(data!=null) {
String url = data.toString();
String[] separated = url.split("/");
id= Integer.parseInt(separated[4]);
}
Поделитесь с друзьями через общий доступ, если у них есть приложение, которое будет показывать возможность открытия с помощью приложения и откроется при активности, установленной в манифесте.
https://developer.android.com/training/app-indexing/deep-linking.html