Last active
November 26, 2015 14:43
-
-
Save GigigoGreenLabs/4fdc6e5594285566b295 to your computer and use it in GitHub Desktop.
Check if a app is installed and go to the market if not. We have to pass the package of the app in the param.
This file contains hidden or 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
PackageUtils.startNewActivity(getApplicationContext(), "com.microsoft.office.lync15"); |
This file contains hidden or 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
public class PackageUtils { | |
public static void startNewActivity(Context context, String packageName) { | |
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName); | |
if (intent == null) { | |
intent = new Intent(Intent.ACTION_VIEW); | |
intent.setData(Uri.parse("market://details?id=" + packageName)); | |
} | |
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
context.startActivity(intent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment