CopyPastor

Detecting plagiarism made easy.

Score: 1.71599942445755; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2016-08-20
by Riyaz Parasara

Original Post

Original - Posted on 2012-06-06
by Cat



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Not possible at all
user permission is required to install application or not
you can redirect to your application
you can do using the market:// prefix please use my sample code read carefully and add your application package name

final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); }

We use a try/catch block here because an Exception will be thrown if the Play Store is not installed on the target device.

You'll want to use the specified `market` protocol:
final String appPackageName = "com.example"; // Can also use getPackageName(), as below startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
Keep in mind, this will crash on any device that does not have the Market installed (the emulator, for example). Hence, I would suggest something like:
final String appPackageName = getPackageName(); // getPackageName() from Context or Activity object try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); }
While using [`getPackageName()`](http://developer.android.com/reference/android/content/Context.html#getPackageName()) from `Context` or subclass thereof for consistency (thanks [@cprcrack](https://stackoverflow.com/users/423171/cprcrack)!). You can find more on Market Intents here: **[link](http://developer.android.com/guide/publishing/publishing.html#marketintent)**.

        
Present in both answers; Present only in the new answer; Present only in the old answer;