Skip to content

Instantly share code, notes, and snippets.

@zaki50
Created February 24, 2011 03:43
Show Gist options
  • Save zaki50/841716 to your computer and use it in GitHub Desktop.
Save zaki50/841716 to your computer and use it in GitHub Desktop.
https なURLから マーケットを開く
/*
こんなintent filter で
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="https" android:host="market.android.com"/>
</intent-filter>
*/
protected void onResume() {
super.onResume();
final Intent original = getIntent();
if (original == null) {
finish();
return;
}
final Uri data = original.getData();
if (data == null) {
finish();
return;
}
final String marketUriString = data.toString().replaceFirst("^https?:", "market:");
final Uri marketUri = Uri.parse(marketUriString);
final Intent i = new Intent(Intent.ACTION_VIEW, marketUri);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(i);
finish();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment