Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button btnRate = (Button) findViewById(R.id.button);
- btnRate.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- onClickRateThisApp(v);
- }
- });
- }
- private boolean isActivityStarted(Intent aIntent) {
- try {
- startActivity(aIntent);
- return true;
- } catch (ActivityNotFoundException e) {
- return false;
- }
- }
- public void onClickRateThisApp(View v) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse("market://details?id=com.tutorial.personal.androidstudiopro"));
- if (!isActivityStarted(intent)) {
- intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.tutorial.personal.androidstudiopro"));
- if (!isActivityStarted(intent)) {
- Toast.makeText(this, "Could not open Android market, please check if the market app installed or not. Try again later", Toast.LENGTH_SHORT).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement