所有人!
我无法使用文档(https://developer.android.com/training/sharing/receive)从Google Plat Store接收网址
首先,我在清单中添加了<intent-filter>
:
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="*/*"/>
</intent-filter>
P.S .:我也尝试将mimeType更改为text/plain
。
在我的MainActivity
中,我写了 this (针对OnCreate
和OnResume
方法):
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if(Intent.ACTION_SEND.equals(action) && type != null){
if("*/*".equals(type)){
addAppDialog.show(getSupportFragmentManager(), "AddBottomSheet");
String getIntentAppName = intent.getStringExtra(Intent.EXTRA_TEXT);
AddAppDialog.appUrl.setText(getIntentAppName);
}
}
但是,操作和类型给了我null
。
如何解决这个问题?