app_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/rate_us"
app:showAsAction="never"
android:title="Rate us"/>
<item android:id="@+id/share_app"
android:title="Share App"
app:showAsAction="never"/>
<item android:id="@+id/privacy_policy"
android:title="Privacy Policy"
app:showAsAction="never"/>
</menu>
MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.app_menu,menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.rate_us:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + "com.putechnodev.civilmcqquiz"));
startActivity(intent);
return true;
case R.id.share_app:
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_TEXT, "My app name");
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
String strShareMessage = "\nHey! I Got new amazing App For preparation of civil engineering and GATE exam\n\n";
strShareMessage = strShareMessage + "https://play.google.com/store/apps/details?id=" + "com.putechnodev.civilmcqquiz";
i.putExtra(Intent.EXTRA_TEXT, strShareMessage);
i.setPackage("com.whatsapp");
startActivity(i);
return true;
case R.id.privacy_policy:
Intent intent2 = new Intent(Intent.ACTION_VIEW, Uri.parse("https://prnc.flycricket.io/privacy.html"));
startActivity(intent2);
return true;
}
return super.onOptionsItemSelected(item);
}
}
0 Comments