首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的Android外卖应用程序不能在Gmail中填充主题和正文文本,但适用于Outlook

我的Android外卖应用程序不能在Gmail中填充主题和正文文本,但适用于Outlook
EN

Stack Overflow用户
提问于 2021-02-05 02:27:16
回答 1查看 11关注 0票数 0

我已经在Android Studio中创建了一个Android外卖订购应用程序,它应该通过电子邮件发送订单,并填写主题和文本正文字段。当我通过Outlook发送邮件时,它会这样做,但当我在模拟器、手机(Android 10)和平板电脑(Android 7)上使用Android G邮件客户端时,它会拒绝填写这些字段-它只会发送一封空白电子邮件。

代码语言:javascript
复制
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",         "emailaddress@email.com", 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..."));
    }
}

外卖点餐应用。

showName是EditText enterName的toString结果

showPhone是EditText enterTelephone的toString结果

showTime是EditText enterTime的toString结果

totalPrice是商品的价格乘以每个商品的数量作为一系列字符串来创建priceMessage的结果

清单:-

代码语言:javascript
复制
 <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>
EN

回答 1

Stack Overflow用户

发布于 2021-02-05 02:43:42

像这样创建你的意图,这对我的应用程序分享到Gmail很有效:

代码语言:javascript
复制
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"emailaddress@email.com"});
...
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66051636

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档