I have created an Android takeaway ordering app in Android Studio which is supposed to send an order by email and fill in subject and text body fields. It does this when I send by Outlook but refuses to fill these fields when I use Android G mail client on emulator, mobile phone (Android 10) and tablet (Android 7) – it just sends a blank email.
public void submitOrder(View view) {
submit_order_quantity = submit_order_quantity + 1;
EditText enterName = findViewById(R.id.nameBar);
String showName = enterName.getText().toString(); //gets you the contents of name edit text
EditText enterTelephone = findViewById(R.id.your_telephone);
String showPhone = enterTelephone.getText().toString(); //gets you the contents of telephone number edit text
EditText enterTime = findViewById(R.id.collect_time);
String showTime = enterTime.getText().toString(); //gets you the contents of telephone number edit text
double totalPrice = calculatePrice();
String priceMessage = createOrderSummary(showName, showPhone, showTime, totalPrice);
if(submit_order_quantity == 1 && totalPrice != 0){
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "[email protected]", null));
// only email apps should handle this
intent.putExtra(Intent.EXTRA_SUBJECT, Restaurant Order for: + showName);
intent.putExtra(Intent.EXTRA_TEXT, priceMessage);
startActivity(Intent.createChooser(intent, "Send email..."));
}
}
Takeaway order app.
showName is toString result of EditText enterName
showPhone is toString result of EditText enterTelephone
showTime is toString result of EditText enterTime
totalPrice is result of price of items multiplied by the quantity of each as a series of Strings to create priceMessage
The Manifest:-
<queries>
<!--
Specific intents you query for,
eg: for a custom share UI
-->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="image/jpeg" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
</intent>
<intent>
<action android:name="android.intent.action.SEND" />
<data android:scheme="mailto" />
</intent>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:mimeType="*/*" />
</intent>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:mimeType="text/plain" />
</intent>
<intent>
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="application/vnd.google.panorama360+jpg"/>
</intent>
<intent>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<data android:mimeType="image/*"/>
</intent>
<intent>
<action android:name="android.intent.action.SEND_MULTIPLE"/>
<data android:mimeType="video/*"/>
</intent>
</queries>
<application
android:allowBackup="true"
android:fullBackupContent="@xml/my_backup_rules"
android:icon="@mipmap/app_logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/app_logo_round"
android:supportsRtl="true"
android:theme="@style/Theme.TakeawayFood">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="message/rfc822" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Starters"
android:label="@string/app_name"
android:parentActivityName=".MainActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".Mains"
android:label="@string/app_name"
android:parentActivityName=".MainActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name=".Desserts"
android:label="@string/app_name"
android:parentActivityName=".MainActivity">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
</application>
question from:
https://stackoverflow.com/questions/66051636/my-android-takeaway-app-wont-fill-subject-and-body-text-in-gmail-but-works-with 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…