如果应用程序安装在设备上,我想在链接点击而不是浏览器上打开我的应用程序,否则打开Google play。 所以搜索后..这是我的清单在链接点击而不是浏览器上打开我的应用程序 - Android
<activity
android:name="example.com.MyActivity"
android:label="@string/title_activity_open_event_details" >
<intent-filter>
<data
android:host="play.google.com"
android:scheme="http"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
,这是我的活动
public class MyActivity extends Activity {
private int EventId;
private TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_open_event_details);
tv = (TextView) findViewById(R.id.testtv);
Uri data = getIntent().getData();
if (data != null)
{
String scheme = data.getScheme();
String host = data.getHost();
List<String> params = data.getPathSegments();
String first = params.get(0);
String second = params.get(1);
int size = params.size();
// EventId = params.get(size-1);
String third = params.get(size-1);
tv.setText(data.toString());
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my_activity, menu);
return true;
}
}
,当我这个链接https://play.google.com/store/apps/details?id=example.com&evid=117 MyActivity成功打开,但显示的链接上点击的TextView只https://play.google.com/store/apps/details?id=example.com没有& evid = 117我需要获取一些数据并将其显示在我的活动中
请问您能否帮助我了解我在想什么G ? 在此先感谢
如果用户选择浏览器为默认应用,会发生什么打开网址? – Salmaan 2015-02-10 04:54:50