Created
February 24, 2011 03:43
-
-
Save zaki50/841716 to your computer and use it in GitHub Desktop.
https なURLから マーケットを開く
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
こんな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