Android 如何获取与我的应用共享数据的应用
我正在构建一个应用程序,其他应用程序可以与之共享文本(链接等) 是否有方法获取与我的应用共享数据的应用的名称Android 如何获取与我的应用共享数据的应用,android,kotlin,Android,Kotlin,我正在构建一个应用程序,其他应用程序可以与之共享文本(链接等) 是否有方法获取与我的应用共享数据的应用的名称 我已经找到了reference.hostwitch,它提供了共享应用程序的URI,但是URI不同(com.reddit.frontpage与com.google.android.youtube),这使得解析变得困难。在清单中添加此代码 <application android:icon="@drawable/ic_launcher" android:label="@
我已经找到了
reference.host
witch,它提供了共享应用程序的URI,但是URI不同(com.reddit.frontpage与com.google.android.youtube),这使得解析变得困难。在清单中添加此代码
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
//Add this line
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
//---------------
</activity>
</application>
我希望这能帮助你
谢谢。不清楚您是否在寻找:太好了!这就是我要找的
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get intent, action and MIME type
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
// You would then use these three variable to figure out who has sent you an Intent and what they want you to do!
// See here for further instruction: https://developer.android.com/training/sharing/receive.html
// https://developer.android.com/guide/topics/manifest/action-element.html
// https://developer.android.com/reference/android/content/Intent.html#ACTION_GET_CONTENT
}
}