AndroidManifest.xml
...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.justjava">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.JustJava">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
... MainActivity.java(Intent Part)
...
public void SubmitOrder(View view) {
EditText enteredName = findViewById(R.id.name_editText_view);
String name = enteredName.getText().toString();
CheckBox checkCream = findViewById(R.id.checkbox1);
boolean whippedCream = checkCream.isChecked();
CheckBox checkChocolate = findViewById(R.id.checkbox2);
boolean chocolate =checkChocolate.isChecked();
int price = calculatePrice(whippedCream,chocolate);
String priceMessage =createOrderSum(name,price,whippedCream,chocolate);
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:")); // only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, "The just java order for"+ name);
intent.putExtra(Intent.EXTRA_TEXT,priceMessage);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}
...
Email intent is not working on my android 11 device but it is working fine on AVD on android versions less than 11. The submit order is not doing any thing in the app. It should send an intent to email app with order summary and subject filled.