Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. Button btnRate = (Button) findViewById(R.id.button);
  2. btnRate.setOnClickListener(new View.OnClickListener() {
  3.  
  4. @Override
  5. public void onClick(View v) {
  6. onClickRateThisApp(v);
  7. }
  8. });
  9. }
  10.  
  11. private boolean isActivityStarted(Intent aIntent) {
  12. try {
  13. startActivity(aIntent);
  14. return true;
  15. } catch (ActivityNotFoundException e) {
  16. return false;
  17. }
  18. }
  19.  
  20. public void onClickRateThisApp(View v) {
  21. Intent intent = new Intent(Intent.ACTION_VIEW);
  22. intent.setData(Uri.parse("market://details?id=com.tutorial.personal.androidstudiopro"));
  23. if (!isActivityStarted(intent)) {
  24. intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.tutorial.personal.androidstudiopro"));
  25. if (!isActivityStarted(intent)) {
  26. Toast.makeText(this, "Could not open Android market, please check if the market app installed or not. Try again later", Toast.LENGTH_SHORT).show();
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement