Guest User

Untitled

a guest
Jun 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. //rateus button
  2. android.widget.Button ratebutton = (android.widget.Button) findViewById(R.id.id_rateus);
  3. ratebutton.setOnClickListener(new View.OnClickListener() {
  4. @Override
  5. public void onClick(View v) {
  6. try {
  7. startActivity(new Intent(Intent.ACTION_VIEW,
  8. android.net.Uri.parse("market://play.google.com/store/apps/details?id=com.slsindupotha&hl=en")));
  9. }catch (android.content.ActivityNotFoundException e){
  10. startActivity(new Intent(Intent.ACTION_VIEW,
  11. android.net.Uri.parse("https://play.google.com/store/apps/details?id=com.slsindupotha&hl=en")));
  12. }
  13. }
  14. });
  15. //end rateus button code
  16.  
  17. <item
  18. android:id="@+id/id_rateus"
  19. android:orderInCategory="100"
  20. android:title="@string/action_rateus"
  21. android:textAllCaps="false"
  22. app:showAsAction="ifRoom" />
  23.  
  24. @Override
  25. public boolean onCreateOptionsMenu(Menu menu) {
  26. MenuInflater inflater = getMenuInflater();
  27. inflater.inflate(R.menu.menu_file, menu);
  28. return true;
  29. }
  30.  
  31. @Override
  32. public boolean onOptionsItemSelected(MenuItem item) {
  33. // Handle item selection
  34. switch (item.getItemId()) {
  35. case R.id.id_rateus:
  36. //handle onclick event for intent to playstore
  37. return true;
  38. default:
  39. return super.onOptionsItemSelected(item);
  40. }
  41. }
  42.  
  43. @Override
  44. public boolean onCreateOptionsMenu(Menu menu) {
  45. // Inflate the menu; this adds appModels to the action bar if it is present.
  46. this.menu = menu;
  47. getMenuInflater().inflate(R.menu.menu_main, menu);
  48. return true;
  49. }
  50.  
  51. @Override
  52. public boolean onOptionsItemSelected(MenuItem item) {
  53. int id = item.getItemId();
  54.  
  55. switch (id) {
  56. switch (item.getItemId()) {
  57. case R.id.share:
  58.  
  59. Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
  60. sharingIntent.setType("text/plain");
  61. String shareBodyText = "Check it out. Your message goes here";
  62. sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Subject here");
  63. sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBodyText);
  64. startActivity(Intent.createChooser(sharingIntent, "Shearing Option"));
  65. return true;
  66.  
  67. case R.id.id_rateus:
  68. try {
  69. startActivity(new Intent(Intent.ACTION_VIEW,
  70. android.net.Uri.parse("market://play.google.com/store/apps/details?id=com.slsindupotha&hl=en")));
  71. }catch (android.content.ActivityNotFoundException e){
  72. startActivity(new Intent(Intent.ACTION_VIEW,
  73. android.net.Uri.parse("https://play.google.com/store/apps/details?id=com.slsindupotha&hl=en")));
  74. }
  75.  
  76. return true;
  77. }
  78.  
  79. return super.onOptionsItemSelected(item);
  80. }
Add Comment
Please, Sign In to add comment